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 |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2009-07-08 : 13:41:35
|
| Done this before, just can't find it.3 params@param1 INT = NULL,@param2 INT = 0,@param3 INT = 0SELECT id FROM myTable WHERE fld1 = @parm1 AND fld2 = @param2 AND fld3 = @param3Now, if param2 or param3 is 0, do NOT include in where clause.The same goes if param1 is null.I know there's a way to set this but just can't remember the syntax.Thanks,Zath |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 13:44:57
|
| [code]..@param1 INT = NULL,@param2 INT = 0,@param3 INT = 0SELECT id FROM myTableWHERE (fld1 = @parm1 OR @parm1 IS NULL)AND (fld2 = @param2 OR @param2=0)AND (fld3 = @param3 OR @param3=0)...[/code] |
 |
|
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2009-07-08 : 13:53:25
|
| I know it was something like that.Thanks, too easy! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 14:02:44
|
| welcome |
 |
|
|
|
|
|