GibboK
GibboK

Reputation: 73918

How to alter a table to add a default value on a column

I use ms sql 2008 I have problem to add a default value to a column on a specific table.

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

Could you tell me what I'm doing wrong here?

Thanks

Upvotes: 1

Views: 376

Answers (2)

4b0
4b0

Reputation: 22323

Try This:

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

Upvotes: 1

Christian Specht
Christian Specht

Reputation: 36421

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

Upvotes: 5

Related Questions