February 19, 2004 at 3:15 am
Suppose you have
declare @bBit bit
To check the TRUE/FALSE of @bBit, which is better:
if not @bBit
or
if ( @bBit = 0 )
Your inputs appreciated.
--
February 19, 2004 at 9:00 am
The BIT datatype is described as an "Integer data type" - see BOL. I do not believe the syntax "not @bbit" will be accepted in the SQL code.
Guarddata-
February 19, 2004 at 9:13 am
Oops!
What I am trying to get at is,
is not (value)
better, or
is ( value = false )
better.
I just used the T-SQL syntax on the fly, so completely missed the bit is integer bit!
--
February 19, 2004 at 9:21 am
When I try to execute SQL code of not (value) or not @variable, I get syntax errors. All our routines check for @bbit = 0 for false and @bbit = 1 for true. The real advantage (to us, at least) in using a BIT datatype is that anything non-zero gets converted to a 1 so you are sure of the evaluations. We still tend to use TINYINT to permit future flexibility of using more values.
Guarddata-
February 19, 2004 at 8:29 pm
'=' will almost always be faster than NOT or != (not equal) Check your optimization plan to confirm and also use "set statistics IO on" to see logical IO.
HTH
------------
Ray Higdon MCSE, MCDBA, CCNA
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply