is there any difference between the follow exemples?
ProjNum int CONSTRAINT nn_ProjNum NOT NULL CONSTRAINT C_ProjNum CHECK (ProjNum >= 10)
ProjNum int NOT NULL CHECK (ProjNum >= 10)
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
Both are same.
In my understanding ,
CONSTRAINT CHECK can be define when you add new columns.
ALTER TABLE dbo.DocExc ADD ColumnD int NULL CONSTRAINT CHK_ColumnD_DocExc CHECK (ColumnD > 10 AND ColumnD < 50); GO
Also user can provide own constraint name.
But if we have to put check in existing column then
ALTER TABLE dbo.DocExc ADD CHECK (ExistsColumn > 10 AND ExistsColumn < 50); GO
system will provide constraint name here.