Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 add Defaults to existing table columns

Author  Topic 

ivankb
Starting Member

1 Post

Posted - 2006-05-23 : 07:34:07
Hi

How can I add a default to an existing table?
(I know I can add a constraint but I'd rather just have a default!)

According to the BOL this should work:

ALTER TABLE table_name
{ [ ALTER COLUMN column_name
{DROP DEFAULT
| SET DEFAULT constant_expression
| IDENTITY [ ( seed , increment ) ]
}

But I get an error - "Incorrect syntax near the keyword 'set'"

Please help if you know!

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-23 : 07:46:47
Try this

ALTER TABLE Table_Name ADD CONSTRAINT
Contraint DEFAULT <Value> FOR Column_Name

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page
   

- Advertisement -