Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Add new column with default value

$
0
0
Hi There,I want to set a default value to a column while adding it. [code="sql"]Create table test(id int )insert into Test values(123)alter table test add column2 int default(0) [/code]In the above query I have set the default value, but it will not set the default value to the already inserted columns.So how to set a default value for the already inserted rows, while adding a new column to it ?

Viewing all articles
Browse latest Browse all 3145

Trending Articles