jwiner
SSCrazy
Points: 2241
More actions
December 2, 2002 at 9:28 am
#80428
Can't quite get the correct syntax for this query below. Any help would be appreciated.
declare @test-2 int
set @test-2 = 1
select top 10 * from table
where field in
case
when @test-2 = 1 then (1, 2)
when @test-2 = 2 then (2, 3)
else (3, 4)
end
Andy Jones, DBA
Hall of Fame
Points: 3641
December 2, 2002 at 9:41 am
#442789
Hi, I think this will work:-
where field between
case @test-2
when 1 then 1
when 2 then 2
else 3
and
when 1 then 2
when 2 then 3
else 4
Regards,
Andy Jones
.
December 2, 2002 at 9:43 am
#442791
I specifically need the 'in' syntax.
pipmaster
Valued Member
Points: 64
December 8, 2002 at 1:35 pm
#443600
how about this
declare @one int, @two int
if @test-2=1
begin
@one=1
@two=2
etc.
select ...
where Col in (@one, @Two)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply