On Transact SQL language the Msg 3726 Level 16 - Could not drop object because it is referenced by a FOREIGN KEY constraint.
Msg 3726 Level 16 Example:
Create tables
USE model;
GO
create table Test_1
(id int not null primary key,
name varchar(500) not null);
GO
create table Test_2
(id int not null primary key,
name varchar(500) not null,
constraint FK_TestID
foreign key (id) references Test_1(id));
GO
Invalid statement:
USE model;
GO
DROP TABLE Test_1;
GO
Message |
---|
Msg 3726, Level 16, State 1, Line 3 |
Could not drop object 'Test_1' because it is referenced by a FOREIGN KEY constraint. |
Correct statement:
USE model;
GO
DROP TABLE Test_2;
GO
DROP TABLE Test_1;
GO
Other error messages:
- Is not a constraint
- Create View or Function failed because no column name was specified
- Cannot define PRIMARY KEY constraint on nullable column in table
- Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
- String or binary data would be truncated
- The database name component of the object qualifier must be the name of the current database
- No item by the name of '%' could be found in the current database.