How can I list all foreign keys referencing a given table in SQL Server?

 how to check if columns in table was used as foreign key in other tables
 

Not sure why no one suggested but I use sp_fkeys to query foreign keys for a given table:

EXEC sp_fkeys 'TableName'

You can also specify the schema:

EXEC sp_fkeys @pktable_name = 'TableName', @pktable_owner = 'dbo'

Without specifying the schema, the docs state the following:

If pktable_owner is not specified, the default table visibility rules of the underlying DBMS apply.

In SQL Server, if the current user owns a table with the specified name, that table's columns are returned. If pktable_owner is not specified and the current user does not own a table with the specified pktable_name, the procedure looks for a table with the specified pktable_name owned by the database owner. If one exists, that table's columns are returned.

测试了一下,还是很给力的。直接给出一张表A,会直接找到那些用了这张表A的字段作为外键 的其他表。

最新文章

  1. 从Elo Rating System谈到层次分析法
  2. iOS7模拟器安装
  3. 《用格式化(fprintf和fscanf函数)的方式读写文件》
  4. System Generator入门
  5. 利用QObject反射实现jsonrpc
  6. 【BZOJ】【2982】Combination
  7. P44、面试题4:替换空格
  8. Java实战之04JavaWeb-08文件上传与下载
  9. BZOJ 4004 [JLOI 2015] 装备购买 解题报告
  10. Node.js事件循环
  11. n多边形面积
  12. 浅析Delphi Container库(有开源的DCLX)
  13. block、inline、inline-block对比
  14. LINUX 笔记-文件隐藏属性
  15. dm642的视频口输出
  16. 数值分析:Hermite多项式
  17. 如何在 Linux 上复制文件/文件夹到远程系统?
  18. 【读书笔记】Segment Routing基础
  19. AnimDynamics简介
  20. thinkphp路由

热门文章

  1. memcached-session-manager 教程实现session共享
  2. 完成向后台添加用户的ssm项目,完整版
  3. POJ:2049Finding Nemo(bfs+优先队列)
  4. hdu1542 Atlantis(矩阵面积的并)
  5. 手工利用Chrome浏览器“Javascript控制台”
  6. keras load model 遇到 自定义函数 Lambda(lambda x: softmax(x, axis=1), NameError: global name 'softmax' is not defined
  7. n的相反数
  8. Bootstrap3-文字样式
  9. Learning to Rank算法介绍:RankNet,LambdaRank,LambdaMart
  10. 谷歌浏览器使用IE内核