プロジェクト

全般

プロフィール

TableList.sql

MS SQL Server で テーブル一覧を出す時に使えるクエリ - 蒲池 晃, 2019/01/09 07:38

 
1
/*
2
        extendedproperty?ɗ\?ߒl?????Ă????ƊǗ??????₷??
3
        MS_Description = ?e?[?u????
4
        Description?@=?@?e?[?u???̗p?r?Ȃǂ̐???
5
*/
6

    
7
select        
8
        ROW_NUMBER() over (order by A.Name) as TableNo,
9
        A.id,
10
        A.Name as TableName,
11
        D.value as TableNameJa,
12
        D2.value as TableDescription,
13
        A.crdate
14
from sys.sysobjects A
15
        left join sys.extended_properties D on
16
                 D.major_id = A.id AND D.minor_id  = 0
17
        left join (Select * From sys.extended_properties where Name='Description') D2 on
18
                 D2.major_id = A.id AND D2.minor_id  = 0
19
where A.xtype='U'        
20
order by A.Name