BIT (TSQL Datatype)
Is a one-byte unsigned integer, containing only 0, 1.
Syntax
BIT
Range
0, 1
Remarks
When a number of another datatype is converted to bit
, any nonzero value is converted to 1.
The storage on disk used by bit
is one byte, not one bit.
Literal Bit
There is no syntax for writing a literal
bit
.
You just use a literal int
, and it will be converted to bit
.
DECLARE @a BIT;
SET @a = 1; -- 1 is a literal 'int'
Examples
DECLARE @a BIT = 1;
DECLARE @b BIT = 0;
PRINT @a & @b;
PRINT @a ^ @b;
The result is:
0
1