If I try to run this query in SQL Server 2005:
SELECT 1 WHERE NOT ( 0 )
I get this error:
Msg 4145, Level 15, State 1, Line 1 An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Sometimes when debugging complex WHERE statements I will cut out pieces and test a particular scenario by inserting something like 1=1
for true. I would prefer to just use 1
or TRUE
but this doesn't work in the above case. Why is it not able to evaluate NOT( 0 )
as a boolean expression?
Edit: This does work fine, showing that I don't have to add a column:
SELECT 1 WHERE NOT(1<>1)