Quantcast
Viewing all articles
Browse latest Browse all 91

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

In SQL Server, you can use below template:

ALTER TABLE {tablename}
ADD 
    {columnname} {datatype} DEFAULT {default_value}

For example, to add a new column [Column1] of data type int with default value = 1 into an existing table [Table1] , you can use below query:

ALTER TABLE [Table1]
ADD 
    [Column1] INT DEFAULT 1

Viewing all articles
Browse latest Browse all 91

Trending Articles



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