Force default value when adding column to table - SQL Server
database, sql-server
Solution
You need two statements. First create the column with not null. Then change the not null constraint to nullable
alter table mytable add mycolumn varchar(10) not null default ('a value')
alter table mytable alter column mycolumn varchar(10) null
Problem
In SQL Server 2000/2005, Is it possible to force the default value to be written to already existing rows when adding a new column to a table without using NOT NULL on the new column?