@manhng

Welcome to my blog!

SQL SERVER - Add New Column With Default Value

April 5, 2018 12:24

SQL SERVER - Add New Column With Default Value

ALTER TABLE [dbo].[tb_admin_users] DROP CONSTRAINT [DF_tb_admin_users_IsEnableGoogleAuth]
GO

ALTER TABLE [dbo].[tb_admin_users] ADD CONSTRAINT [DF_tb_admin_users_IsEnableGoogleAuth] DEFAULT ((0)) FOR [IsEnableGoogleAuth]
GO 

SQL SERVER - Add New Column With Default Value

https://blog.sqlauthority.com/2011/04/09/sql-server-add-new-column-with-default-value/

ALTER TABLE {TABLENAME} 
ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} 
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
WITH VALUES

Categories

Recent posts