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 |
|
PeterG
Posting Yak Master
156 Posts |
Posted - 2002-04-30 : 17:41:12
|
| This is my sp:declare @all bitselect @all=blnAllowAll from table1if @all = null select * from table2...I get this error when I run this on Query analyzer:"Syntax error converting the varchar value 'null' to a column of data type bit."How do I fix this? Thanks. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-04-30 : 17:47:40
|
| This should work:declare @all bit select @all=blnAllowAll from table1 if @all IS Nullselect * from table2You should ALWAYS use Is Null when testing for Null, instead of using the = sign. Even though you can SET ANSI_NULLS ON and use equals, Is Null always works regardless of setting. It is also a good idea to embrace the concept that Null does not "equal" anything, even another Null. |
 |
|
|
|
|
|