Adding new non nullable column to SQL table with default value

01 Nov 2020

sql
ALTER TABLE [schema].[Table]
ADD [NewColumn] INT NOT NULL CONSTRAINT [DF_Table_NewColumn] DEFAULT 2
GO

ALTER TABLE [schema].[Table] DROP CONSTRAINT [DF_Table_NewColumn]
GO

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.