Sql Server 2005 Tip:Implicit Conversion of bit data types

Didn't you know that the following statement is now valid for Sql Server 2005 as criteria for a column with bit data type?

SELECT * FROM Orders WHERE Processed = 'true'

The engine is now intelligent enough to implicitly convert it to

SELECT * FROM Orders WHERE Processed = 1

More readable, imo. Too bad it's Sql Server 2005 only.


 
Published 12-10-2006 9:47 AM by bonskijr
Filed under: , ,

Comments

# re: Sql Server 2005 Tip:Implicit Conversion of bit data types

I think that conversion is default now. Even if you query the results of bit values, it defaults to 'True' and 'False' instead of 1 and 0

Tuesday, December 19, 2006 1:52 AM by LaTtEX

# re: Sql Server 2005 Tip:Implicit Conversion of bit data types

Really? Im using SMMSX, it still displays the 1/0 values.

like:

SELECT * FROM master..MSreplication_options WHERE value = 'true'

displays:

optname        value

-------------  ------

transactional     1

merge             1

Tuesday, December 19, 2006 4:58 AM by bonskijr