title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | ms.custom | f1_keywords | helpviewer_keywords | dev_langs | monikerRange | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bit (Transact-SQL) |
The bit data type is an integer data type that can take a value of 1, 0, or NULL, representing Boolean values. |
MikeRayMSFT |
mikeray |
randolphwest |
09/24/2024 |
sql |
t-sql |
reference |
|
|
|
|
>=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric |
[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw-fabricsqldb]
An integer data type that can take a value of 1
, 0
, or NULL
.
The [!INCLUDE ssDEnoversion] optimizes storage of bit columns. If there are 8 or fewer bit columns in a table, the columns are stored as 1 byte. If there are from 9 up to 16 bit columns, the columns are stored as 2 bytes, and so on.
The bit data type can be used to store Boolean values. The string values TRUE
and FALSE
can be converted to bit values: TRUE
is converted to 1
, and FALSE
is converted to 0
.
Converting to bit promotes any nonzero value to 1
.
The bit data type supports the COUNT function. However, other standard aggregate functions, like SUM
, AVG
, MIN
, and MAX
, don't directly support the bit data type.