Quantcast
Channel: How to add a column with a default value to an existing table in SQL Server? - Stack Overflow
Viewing all articles
Browse latest Browse all 91

Answer by Somendra Kanaujia for Add a column with a default value to an existing table in SQL Server

$
0
0
ALTER TABLE <YOUR_TABLENAME>ADD <YOUR_COLUMNNAME> <DATATYPE> <NULL|NOT NULL> ADD CONSTRAINT <CONSTRAINT_NAME>   ----OPTIONALDEFAULT <DEFAULT_VALUE>

If you are not giving constrain name then sql server use default name for this.

Example:-

ALTER TABLE TEMP_TABLENAMEADD COLUMN1 NUMERIC(10,0) NOT NULLADD CONSTRAINT ABCDE   ----OPTIONALDEFAULT (0)

Viewing all articles
Browse latest Browse all 91

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>