How can I find out what FOREIGN KEY constraint references a table in SQL Server?

前端 未结 15 755
再見小時候
再見小時候 2020-12-04 05:12

I am trying to drop a table but getting the following message:

Msg 3726, Level 16, State 1, Line 3
Could not drop object \'dbo.UserProfile\' bec

15条回答
  •  时光取名叫无心
    2020-12-04 05:44

    Try this

    SELECT
      object_name(parent_object_id) ParentTableName,
      object_name(referenced_object_id) RefTableName,
      name 
    FROM sys.foreign_keys
    WHERE parent_object_id = object_id('Tablename')
    

提交回复
热议问题