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
 General SQL Server Forums
 New to SQL Server Programming
 Default constraints

Author  Topic 

honeytjames
Starting Member

3 Posts

Posted - 2008-10-07 : 23:32:03
Hi,

I know we can use the following code to specify default constraints for a new column but can someone tell me how to specify a default constraint for an already existing column?

ALTER TABLE TestTable
ADD NewCol VARCHAR(50)
CONSTRAINT DF_TestTable_NewCol DEFAULT '' NOT NULL
GO

Any help would be greatly appreciated!!!Thanx in advance..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-07 : 23:33:00
use alter table alter column
ALTER TABLE TestTable
ALTER COLUMN NewCol VARCHAR(50)
CONSTRAINT DF_TestTable_NewCol DEFAULT '' NOT NULL
GO
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-10-08 : 11:55:18
ALTER TABLE TestTable
ADD CONSTRAINT DF_TestTable_NewCol DEFAULT '' FOR NewCol
Go to Top of Page
   

- Advertisement -