첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
SELECT
    A.TABLE_CATALOG      AS [Database]
   ,A.TABLE_SCHEMA       AS [Schema]
   ,A.TABLE_NAME         AS [Table]
   ,A.CONSTRAINT_CATALOG AS ConstraintDatabase
   ,A.CONSTRAINT_SCHEMA  AS ConstraintSchema
   ,A.CONSTRAINT_NAME    AS [Constraint]
   ,CASE A.CONSTRAINT_TYPE
        WHEN 'PRIMARY KEY' THEN 'PK'
        WHEN 'FOREIGN KEY' THEN 'FK'
        WHEN 'CHECK'       THEN 'CK'
        WHEN 'UNIQUE'      THEN 'UK'
        ELSE                    ''
    END                  AS ConstraintType
   ,CASE A.IS_DEFERRABLE
        WHEN 'YES' THEN 'Y'
        WHEN 'NO'  THEN 'N'
        ELSE            ''
    END                  AS IsDeferrable
   ,CASE A.INITIALLY_DEFERRED
        WHEN 'YES' THEN 'Y'
        WHEN 'NO'  THEN 'N'
        ELSE            ''
    END                 AS InitiallyDeferred
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS A
WHERE A.TABLE_NAME <> 'sysdiagrams'
ORDER BY
    A.TABLE_NAME      ASC
   ,A.CONSTRAINT_TYPE DESC;
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요