如何更改表以在列上添加默认值

时间:2011-08-22 15:35:21

标签: sql sql-server sql-server-2008

我使用ms sql 2008我有问题要在特定表的列上添加默认值。

ALTER TABLE dbo.CmsAuthors
ALTER COLUMN IsContentAuthorPublished
  ADD CONSTRAINT DF_CmsAuthors_IsContentAuthorPublished DEFAULT 0

你能告诉我这里我做错了什么吗?

由于

2 个答案:

答案 0 :(得分:5)

ALTER TABLE dbo.CmsAuthors
ADD CONSTRAINT DF_CmsAuthors_IsContentAuthorPublished  
DEFAULT 0 FOR IsContentAuthorPublished

答案 1 :(得分:1)

试试这个:

ALTER TABLE dbo.CmsAuthors
    ALTER COLUMN IsContentAuthorPublished
     ADD CONSTRAINT DF_CmsAuthors_IsContentAuthorPublished DEFAULT 0
 for <Column Name>