Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Case in Where

Author  Topic 

JAdauto
Posting Yak Master

160 Posts

Posted - 2008-10-03 : 00:11:18
I have a situation where I am sending a numerical value for a marina type and if that value is 0, I want to return both the 3 and 4's. I know that those will be the only three values that I could possibly receiving.

Dry Type = 3
Wet Type = 4
View All = 0

My where section query looks something like this:


WHERE ms.MarinaTypeENUM =

CASE @ll_MarinaTypeID
WHEN 0 then 0
ELSE @ll_MarinaTypeID
END



but this does not handle the 0 portion. I was thinking I could change @ll_MarinaTypeID to a string variable and send the numbers like (3), (4) or (3,4) and make it be like

WHERE ms.MarinaTypeENUM IN @ls_MarinaTypeID


But that doesn't work either. I know I am only sending you a portion of what I need, so if I need to send you the rest, let me know. This seems like it should be so easy, I cannot believe I am not seeing the solution. Thx.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 00:15:44
WHERE (ms.MarinaTypeENUM = @ll_MarinaTypeID OR @ll_MarinaTypeID=0)
Go to Top of Page

JAdauto
Posting Yak Master

160 Posts

Posted - 2008-10-03 : 00:25:15
BEAUTIFUL! Works like a charm. Used the same thing for the other three variables that I am doing! Thanks for the speedy response!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 00:36:30
quote:
Originally posted by JAdauto

BEAUTIFUL! Works like a charm. Used the same thing for the other three variables that I am doing! Thanks for the speedy response!


welcome
Go to Top of Page
   

- Advertisement -