开发者

MS SQL Server Import - Importing Data With New NON NULL Column

I am trying to imp开发者_JAVA技巧ort from an old database into an updated one.

The databases are basically identical except in one of my tables I added a new column that is NOT NULL.

This obviously makes errors when I used the importer to move the rows over. Is there a way that I can define a default for this new NOT NULL field when doing an Import?


Yes you can add a default constraint to the new column. See this post: Alter column, add default constraint

alter table TableName
add constraint df_ConstraintNAme
default > getutcdate() for [Date]


Two options are:

1) Define a DEFAULT value constraint on the column

2) Temporarily make the column NULL, do the import, then reapply the NOT NULL constraint

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜