filmov
tv
Could not drop object because it is referenced by a FOREIGN KEY constraint SQL Server

Показать описание
SQL Server / T-SQL Tutorial Scenario:
You are working as SQL Server DBA or Developer, You need to drop a table from a database. When you execute drop table SchemaName.TableName statement, you get below error.
Msg 3726, Level 16, State 1, Line 12
Could not drop object 'SchemaName.TableName' because it is referenced by a FOREIGN KEY constraint.
Now we know that the table is referenced by Foreign Key Constraint. The problem is how to find which table has that Foreign Key Constraint that is referencing to this table.
You are working as SQL Server DBA or Developer, You need to drop a table from a database. When you execute drop table SchemaName.TableName statement, you get below error.
Msg 3726, Level 16, State 1, Line 12
Could not drop object 'SchemaName.TableName' because it is referenced by a FOREIGN KEY constraint.
Now we know that the table is referenced by Foreign Key Constraint. The problem is how to find which table has that Foreign Key Constraint that is referencing to this table.