Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

SQL Server bit columns can be addressed with 'false' and 'true' as well as 0 and 1

Jan 26 2012 12:27AM by ErikEckhardt   

I have worked with SQL Server bit columns for years, yet even so, to my surprise I just learned that you can not only use 1 and 0, you can also use the literals 'true' and 'false'. Note that they are not explicitly bit data types already, but like 1 and 0 implicitly convert to bit with no problem:

DECLARE @Doors TABLE (
    DoorID int NOT NULL identity(1,1),
    IsOpen bit NOT NULL
);

INSERT @Doors (IsOpen) VALUES ('True');
INSERT @Doors (IsOpen) VALUES (0);
INSERT @Doors (IsOpen) VALUES ('False');
INSERT @Doors (IsOpen) VALUES (1);

SELECT * FROM @Doors;
SELECT * FROM @Doors WHERE DoorID = 3 OR IsOpen = 'True';

Examination of execution plans will show that using 'true' and 'false' is slightly different from 1 and 0 since a "convert implicit" operation is excluded in some cases with them.

Read More..   [32134 clicks]

Published under: SQL Server Tips ·  ·  ·  · 


ErikEckhardt
65 · 3% · 887
16
 
11
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

1  Comments  

Your Comment


Sign Up or Login to post a comment.

"SQL Server bit columns can be addressed with 'false' and 'true' as well as 0 and 1" rated 5 out of 5 by 16 readers
SQL Server bit columns can be addressed with 'false' and 'true' as well as 0 and 1 , 5.0 out of 5 based on 16 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]