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 |
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2009-11-19 : 10:35:20
|
| Hello,The query below does not return any records.declare @value tinyintset @value = nullselect field1from table1where field2 = 1 and field3 = nullThe query below does return value because I am using and field3 is nulldeclare @value tinyintset @value = nullselect field1from table1where field2 = 1 and field3 is nullQuestionHow can I make the query below to return results by passing a parameter for the value, See query belowNote that this query gives an error because I am using = @valueThanksdeclare @value tinyintset @value = nullselect field1from table1where field2 = 1 and field3 = @value |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-11-19 : 11:47:40
|
| Why would using field3 = @value give you an error? Do you want to pass @value in as a null sometimes? If a value is provided, do you not want where field3 is null?and isnull(field3,0) = isnull(@value,0)JimEveryday I learn something that somebody else already knew |
 |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2009-11-20 : 03:59:04
|
| I see.Thank you |
 |
|
|
|
|
|