Skip to content

Latest commit

 

History

History
44 lines (36 loc) · 2 KB

bit-transact-sql.md

File metadata and controls

44 lines (36 loc) · 2 KB
title bit (Transact-SQL)
description The bit data type is an integer data type that can take a value of 1, 0, or `NULL`, representing Boolean values.
author MikeRayMSFT
ms.author mikeray
ms.reviewer randolphwest
ms.date 05/21/2024
ms.service sql
ms.subservice t-sql
ms.topic reference
f1_keywords
bit_TSQL
bit
helpviewer_keywords
bit data type
Boolean
dev_langs
TSQL
monikerRange >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric

bit (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw]

An integer data type that can take a value of 1, 0, or NULL.

Remarks

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.

Related content