SQLSERVER 通过约束名称 检索 该约束所在表
SQLSERVER 通过约束名称 检索 该约束所在表
SELECT
tab.name AS [表名],
idx.name AS [主键名称],
col.name AS [主键列名]
FROM
sys.indexes idx
JOIN sys.index_columns idxCol
ON (idx.object_id = idxCol.object_id
AND idx.index_id = idxCol.index_id
AND idx.is_primary_key = 1)
JOIN sys.tables tab
ON (idx.object_id = tab.object_id)
JOIN sys.columns col
ON (idx.object_id = col.object_id
AND idxCol.column_id = col.column_id)
where idx.name='pk_cbm1_cbm01' ---约束名称
相关文章