> Why then when I display the select results do I see value of -1?
Display the select results WHERE? In Access? VB? This is likely due to
the formatting of the client tool you are using. Try running the select in
a query window in Management Studio (not "open table").
> And in Management Studio table display I see True or False
Yes, this was a bonehead-ed decision by someone who mistook BIT for BOOLEAN
and programmed the grid using the .NET data type instead of understanding
what he/she was actually doing. See these URLs:
connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=124584
connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=264592
connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=330293
Sadly, this problem is identical in SQL Server 2008. :-(
> Also, help says I can refer to 0 or 1 as FALSE or TRUE yet I dont see these
> values in the reserved words.
What help? Be specific. If there is help around the management studio grid
(e.g. Open table), then it means you can use TRUE or FALSE when typing in
data as a string (this is not the same as a keyword or reserved word). Did
the help mention that open table does not accept 1 or 0? It doesn't. And
did it show any examples of using TRUE or FALSE in a query (as keywords, not
as strings)? It couldn't have, because
> Can I say
> Declare MyBit BIT
> If MyBit = TRUE
No, did you try it? When I do this:
DECLARE @MyBit BIT;
SET @MyBit = TRUE;
I get msg 207, "Invalid column name 'TRUE'."
You can, for some reason, do this against 2005 or better, but it yields msg
245 in 2000:
DECLARE @MyBit BIT;
SET @MyBit = 'FALSE';
(Note that 'FALSE' is a string, not a keyword.)
For true, you can also use 'TRUE' or 'tRuE' or 'true' or -1 or 1 or 6 or e
or pi or your weight or your age or your phone number or your birth year or
ridiculously large numbers, e.g.
DECLARE @MyBit BIT;
SET @MyBit = -21271827182718271.87871827182; -- <= 38 significant digits
SELECT @MyBit;
My suggestion: stay away from open table. And always use 0 or 1 for BIT
values. Modify your data in a query window. This is not a spreadsheet and
sadly Microsoft has tried to make the distinction blurry by encouraging this
kind of behavior and messing it up in the process. My guess is that someday
they will fix this ungodly mess and either add BOOLEAN or fix the way BIT is
handled or both. Some things will need to remain for backward compatibility
but there is plenty of room for improvement.
steve dassin - 26 Jul 2008 00:57 GMT
Laser focused. Awesome :-)
>> Why then when I display the select results do I see value of -1?
>
[quoted text clipped - 73 lines]
> compatibility
> but there is plenty of room for improvement.