declare @a int; set @a=1; select * from vehicles where company in ( case when @a=1 then (3,4) else (2)) end
declare @a int declare @str varchar(30) declare @query varchar(500) set @a=1 set @str = '2' if @a = 1 begin set @str = '3,4' end set @query = 'select * from vehicles where company in (' + @str + ')' exec (@query)
DECLARE @a INT; SET @a=1; SELECT * FROM vehicles WHERE 1 = (CASE WHEN @a=1 AND company IN (3,4) THEN 1 WHEN @a=2 AND company=2 THEN 1 END)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)