Thursday, April 14, 2011

Alter Column Default value in SQL Server 2008

since i use the bulkcopy to import data from excel sheet to sql server 2008. there is no such date added column

in the excel sheet to match the dateadded column in sql server, i decide to update the column dateadded to default value GetDate() to have the current date.

in google there are lots of suggestion... even the MSDN sample is not working

finally i found a working example http://sqlserverplanet.com/ddl/add-column-default-value/

here is the sql syntax to update existing column with default value.

ALTER TABLE [dbo].MyTable ADD  DEFAULT (getdate()) FOR DateAdded

No comments:

Post a Comment