Revision: 64151
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 9, 2013 23:24 by keidash
Initial Code
SET NOCOUNT ON Declare @Sede varchar(10) SET @Sede = 'TD' Declare @listas table(Origen varchar(2)) INSERT @listas VALUES('AF') INSERT @listas VALUES('CP') INSERT @listas VALUES('LL') INSERT @listas VALUES('EC') INSERT @listas VALUES('PE') INSERT @listas VALUES('ZZ') SELECT * FROM @listas WHERE 1 = CASE WHEN @Sede = 'TD' THEN CASE WHEN Origen IN ('AF','CP','LL','EC','PE') THEN 1 ELSE 0 END WHEN @Sede = 'SS' THEN CASE WHEN Origen IN ('LL','EC','PE') THEN 1 ELSE 0 END ELSE CASE WHEN Origen = @Sede THEN 1 ELSE 0 END END SET NOCOUNT OFF
Initial URL
Initial Description
How to get a query based on case/when sintax, on WHERE statement (Treated as boolean expresion)
Initial Title
CASE IN WHERE SENTENCE
Initial Tags
sql
Initial Language
SQL