How to Add a Default Value to a Column in SQL Server in SQL Server

To add a default value to a column in SQL Server, use the ALTER TABLE .. ADD CONSTRAINT .. DEFAULT .. FOR command:

-- example: products have a default category of 1
alter table products
add constraint df_category
default 1 for category;
Cta

Shared queries and folders ✅ Version history ✅ One-click connection to SQL Server ✅

Get more done, together, with PopSQL and SQL Server