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.
Author |
Topic |
calvinfoo
Posting Yak Master
129 Posts |
Posted - 2014-06-22 : 21:30:43
|
Hi Gurus,I have a problem with SP when passing in Parameters. Basically something like this:-- Pass 1, 2 or 3 as parameterEXEC SP_mySP 1-- The SP will do the following SQL StatementSELECT * FROM myTable WHERE((If @Parameter1 = 1 then myColumn = 'A' or myColumn = 'B')(If @Parameter1 = 2 then myColumn = 'C')(If @Parameter1 = 3 then myColumn is not null)) How to make the above condition? |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2014-06-23 : 02:01:54
|
select * from mytablewhere (@Parameter = 1 and (myCol = 'A' or myCol = 'B'))or(@Parameter = 2 and myCol = 'C')or(@Parameter = 3 and myCol is not null) Too old to Rock'n'Roll too young to die. |
 |
|
calvinfoo
Posting Yak Master
129 Posts |
Posted - 2014-06-23 : 22:24:14
|
Thanks! It works perfectly! |
 |
|
|
|
|