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 |
|
bill_
Starting Member
38 Posts |
Posted - 2010-05-19 : 12:39:18
|
| How do you put conditional logic in a WHERE clause of a query ia a stored procedure?First need to make TBLX if @PARAM1 is not empty. It is a list codes from a code table.Next need to do something like WHERE CONDITION1 AND CONDITION2 AND IF LEN(@PARAM1)>1 @PARAM1 IN (SELECT X FROM TBLX)Just to start learning the very basics, I tried what's below with no luck to see if query would get no rows - got error cursor not open WHERE COND1 AND COND2 AND IF (0=0) 0=1 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-19 : 12:49:13
|
| WHERE CONDITION1 AND CONDITION2 AND( LEN(@PARAM1)<1 OR @PARAM1 IN (SELECT X FROM TBLX))------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
|
|
|