To extend the Kapil response and avoid the unwanted default restriction, try the following:
ALTER TABLE tablename ADD newcolumn type NOT NULL CONSTRAINT DF_TMP_TABLENAME_NEWCOLUMN DEFAULT -9999 Go Update tablename SET newcolumn = oldcolumn Go ALTER TABLE tablename DROP CONSTRAINT DF_TMP_TABLENAME_NEWCOLUMN Go
Replace -9999 with "noData" if your type is varchar, nvarchar, datetime, ... or any compatible data for other types: the specific value does not matter, it will be destroyed by the second instruction.
Frédéric Chauvière Apr 21 '17 at 15:57 2017-04-21 15:57
source share