Tuesday, January 22, 2013

tsql add default constraint



IF NOT EXISTS(select * from sys.DEFAULT_CONSTRAINTS where NAME like 'def_myconstraint1%')
BEGIN

 ALTER TABLE mytable1
 ADD CONSTRAINT def_myconstraint1 DEFAULT 1 FOR mycolumn1
END
GO

No comments: