SQL Server Interview Question #28

What is BIT in SQL Server?

Data Types, Keys & Constraints Junior Beginner

Detailed Explanation

BIT is a data type commonly used for Boolean-style values. It can store 0, 1, or NULL when the column is nullable.

In application code, a non-nullable BIT column usually maps naturally to a C# bool property in Entity Framework Core.

BIT is commonly used for fields such as IsActive, IsDeleted, IsFeatured, or EmailConfirmed.

Code Example

CREATE TABLE Users
(
    Id INT IDENTITY PRIMARY KEY,
    Email NVARCHAR(256) NOT NULL,
    IsActive BIT NOT NULL DEFAULT 1
);