SELECT table_name,fk_name,reference_table_name,fk_list_number,fk_detail
FROM (
SELECT object_name(f.object_id) AS fk_name,
object_name(f.parent_object_id) AS table_name,
object_name(f.referenced_object_id) AS reference_table_name,
k.constraint_column_id AS fk_list_number,
convert(sysname, col_name(k.referenced_object_id, k.referenced_column_id)) AS fk_detail
FROM sys.foreign_keys f
INNER JOIN sys.foreign_key_columns k
on f.object_id = k.constraint_object_id and f.referenced_object_id = k.referenced_object_id
) t

posted on 2015-03-03 18:18  丢た壳の蜗牛  阅读(1204)  评论(0编辑  收藏  举报