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 - 2011-03-28 : 03:04:08
|
Dear Gurus,In Store Proceedures, how do I the WHERE condition if it is null? Currently it considered Example:EXEC my_SP null, 123456-- inside my_SP:SELECT * FROM my_table WHERE 0=0 AND Value1 = @Value1AND Value2 = @Value2 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-28 : 03:58:24
|
[code]WHERE (@Value1 IS NULL OR Value1 = @Value1)AND (@Value2 IS NULL OR Value2 = @Value2)[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
calvinfoo
Posting Yak Master
129 Posts |
Posted - 2011-03-28 : 21:28:10
|
This works perfectly! Thanks! |
|
|
|
|
|