獲取MS SQL庫資料字典的經典SQL語句

2021-04-07 08:14:11 字數 1357 閱讀 7541

獲取ms sql庫資料字典的經典sql語句

select sysobjects.name as [table], sysproperties.[value] as 表說明,

syscolumns.name as field, properties.[value] as 字段說明, systypes.name as type,

syscolumns.length, isnull(columnproperty(syscolumns.id, syscolumns.name,

'scale'), 0) as 小數字數, syscolumns.isnullable as isnull,

case when syscomments.text is null

then '' else syscomments.text end as [default],

case when columnproperty(syscolumns.id, syscolumns.name, 'isidentity')

= 1 then '√' else '' end as 標識, case when exists

(select 1

from sysobjects

where xtype = 'pk' and name in

(select name

from sysindexes

where indid in

(select indid

from sysindexkeys

where id = syscolumns.id and colid = syscolumns.colid)))

then '√' else '' end as 主鍵

from syscolumns inner join

sysobjects on sysobjects.id = syscolumns.id inner join

systypes on syscolumns.xtype = systypes.xtype left outer join

sysproperties properties on syscolumns.id = properties.id and

syscolumns.colid = properties.**allid left outer join

sysproperties on sysobjects.id = sysproperties.id and

sysproperties.**allid = 0 left outer join

syscomments on syscolumns.cdefault = syscomments.id

where (sysobjects.xtype = 'u')

獲取MS SQL庫資料字典的經典SQL語句

獲取ms sql庫資料字典的經典sql語句 select sysobjects.name as table sysproperties.value as 表說明,syscolumns.name asfield,properties.value as 字段說明,systypes.name astype...

sqlserver 獲取資料字典的經典指令碼

select sysobjects.name as table sysproperties.value as 表說明,syscolumns.name as field,properties.value as 字段說明,systypes.name as type,syscolumns.length,i...

mssql 2005 ,2008匯出資料字典

在你要匯出資料字典的資料空中右鍵,新建查詢,執行如下 即可 select case when a.colorder 1 then d.name else end 表名,d.xtype as 表型別,a.colorder 字段序號,a.name 欄位名,case when columnproperty...