SQL常用系统信息语句
Posted 学习永無止境
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL常用系统信息语句相关的知识,希望对你有一定的参考价值。
一.查询指定表外键约束
SELECT A.name AS 约束名 ,
OBJECT_NAME(B.parent_object_id) AS 外键表 ,
D.name AS 外键列 ,
OBJECT_NAME(B.referenced_object_id) AS 主健表 ,
C.name AS 主键列
FROM sys.foreign_keys A
INNER JOIN sys.foreign_key_columns B ON A.object_id = B.constraint_object_id
INNER JOIN sys.columns C ON B.parent_object_id = C.object_id
AND B.parent_column_id = C.column_id
INNER JOIN sys.columns D ON B.referenced_object_id = D.object_id
AND B.referenced_column_id = D.column_id
WHERE OBJECT_NAME(B.referenced_object_id) = ‘Position‘;
以上是关于SQL常用系统信息语句的主要内容,如果未能解决你的问题,请参考以下文章
sql server中的全局变量,常用的没有多少...以后看看就行