The easiest solution is to alter the table and define the column to allow NULLs, then add in the default data values using the UPDATE T-SQL command, and next, alter the column to NOT NULL.
ALTER TABLE AdventureWorksLT.SalesLT.Customer
ADD temp int NULL
GO
UPDATE AdventureWorksLT.SalesLT.Customer
SET temp = 0
GO
ALTER TABLE AdventureWorksLT.SalesLT.Customer
ALTER COLUMN temp int NOT NULL
GO
No comments:
Post a Comment