SELECT OBJECT_NAME(fc.parent_object_id) AS FROM_TABLE
, OBJECT_NAME(fc.referenced_object_id) AS TO_TABLE
, from_c.name AS FROM_COLUMN_NAME
, to_c.name AS TO_COLUMN_NAME
, fk_obj.name AS FK_NAME
, fk_obj.create_date AS FK_CREATE_DATE
FROM sys.foreign_key_columns fc
JOIN sys.columns to_c
ON to_c.object_id = fc.referenced_object_id
AND to_c.column_id = fc.referenced_column_id
JOIN sys.columns from_c
ON from_c.object_id = fc.parent_object_id
AND from_c.column_id = fc.parent_column_id
JOIN sys.objects fk_obj
ON fk_obj.object_id = fc.constraint_object_id
ORDER BY OBJECT_NAME(from_c.object_id);
'Databases' 카테고리의 다른 글
최대 성능을 보장하기 위해 사용자 지정 MySQL의 설정 파일 (0) | 2011.12.12 |
---|---|
MS SQL 테이블 명세서 출력쿼리 (0) | 2011.08.07 |
Microsoft SQL Server PHP (0) | 2011.08.02 |
SQL Server 액세스를 허용하도록 Windows 방화벽 구성 (0) | 2011.07.31 |
PHP Driver for SQL Server now in the PHP Manual (0) | 2011.07.29 |