Friday, February 10, 2012

bit field

HI,

while saving in bit field sometimes it is saved as true or false. sometimes it is saved as 0 or 1.

how to make it true or false when i needed.

if i set default value to 0 will it save 1 or 0 always.

with default 0 i need to store truee or false. how it is possible this way.

thanks

venp

Hi,

the bit data type always stores either 0 (which is false) or 1 (which is true). A default value is used if no value is explictly passed through.

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

HI jens,

sometimes it stores the word True or False(bit field) thats why i'm confused.

i need to know when it stores 0 or False and 1 or True.

it is confusing me a lot.

venp

|||

Hi,

no the BIT data type is a INT type with the constraint of holding only 0 or 1. The true or false is a client presentation you are seeing, Excel will for example use this presentation for the boolean type.

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

Hi,

00

TrueFalse
01TrueFalse
02TrueFalse
210TrueFalse
220TrueFalse
250TrueFalse
03FalseFalse

the above values i copied from table. true ,false fields are bit datatype.

venp--

|||Where did you copied the output from ?|||

from sqlserver table .i opened the table in sql server and copied.

venp--

|||Do the same query in the query window of SSMS and you will see that this is just a question of presentation. SSMS will display BIT as true / false but SQL Server stores 1/0.

-Jens.|||

you are right

venp--

No comments:

Post a Comment