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
时间: 2024-10-26 09:09:10