T-SQL Tutorial

Msg 3728 Level 16 - Is not a constraint


Transact sql error message Msg 3728 Level 16 - Is not a constraint - means that the constraint name you want to drop is misspelled or do not exist.

Msg 3728 Level 16 Example:

USE model;
GO
CREATE TABLE students( id INT NOT NULL PRIMARY KEY, first_name CHAR(50), last_name CHAR(50),
gender CHAR(1), city CHAR(100), country CHAR(50), dep_id INT);
GO

Invalid alter table:

USE model;
GO
ALTER TABLE students DROP CONSTRAINT id ;
GO

Message
Msg 3728, Level 16, State 1, Line 1
'id' is not a constraint.
Msg 3727, Level 16, State 0, Line 1
Could not drop constraint. See previous errors.

Correct alter table:

USE model;
GO
ALTER TABLE students DROP CONSTRAINT PK__students__3213E83F18691F2B ;
GO

Message
Command(s) completed successfully.

Other error messages: