Today I came across an old table with a datetime column called "Created", which allows null. Now I want to change this so that it is NOT NULL, and also include a restriction to add a default value (getdate ()).
So far, I have the following script that works fine, provided that I cleared all zeros in advance:
ALTER TABLE dbo.MyTable ALTER COLUMN Created DATETIME NOT NULL
Can I also specify a default value in an ALTER statement?
sql sql-server alter-table alter-column
Jim B Jul 06 '10 at 13:50 2010-07-06 13:50
source share