Skip to content

Latest commit

 

History

History
45 lines (38 loc) · 2.12 KB

File metadata and controls

45 lines (38 loc) · 2.12 KB
title bit (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 07/23/2017
ms.prod sql
ms.prod_service database-engine, sql-database, sql-data-warehouse, pdw
ms.reviewer
ms.technology t-sql
ms.topic language-reference
f1_keywords
bit_TSQL
bit
dev_langs
TSQL
helpviewer_keywords
bit data type
ms.assetid 40adfd08-a31c-49cb-a172-386bcaa6edee
author MikeRayMSFT
ms.author mikeray
manager craigg
monikerRange >=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current

bit (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-all-md]

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

Remarks

The [!INCLUDEssDEnoversion] 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 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.

See also

ALTER TABLE (Transact-SQL)
CAST and CONVERT (Transact-SQL)
CREATE TABLE (Transact-SQL)
Data Type Conversion (Database Engine)
Data Types (Transact-SQL)
DECLARE @local_variable (Transact-SQL)
SET @local_variable (Transact-SQL)
sys.types (Transact-SQL)