示例:
CREATE TABLE AA (
BB INT UNIQUE
);
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_unique_constraint = 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
tab.name = 'AA'
结果:
表名 约束名称 约束列名
AA UQ__AA__3214B5C34460231C BB
作者:bugDemo 发表于2013-3-30 13:45:48 原文链接
阅读:0 评论:0 查看评论