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

2021-05-25 01:56:52 字數 1904 閱讀 1210

--

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

select

sysobjects.name as[

table

], sysproperties.

[value]as

表說明,

syscolumns.name

asfield, properties.

[value]as

字段說明, systypes.name

astype,

syscolumns.length,

isnull

(columnproperty

(syscolumns.id, syscolumns.name,

'scale

'), 0)

as小數字數, syscolumns.isnullable

asisnull

, case

when

syscomments.

text

isnull

then

''else

syscomments.

text

endas

[default],

case

when

columnproperty

(syscolumns.id, syscolumns.name,

'isidentity')

=1then'√

'else

''end

as標識,

case

when

exists

(select

1from

sysobjects

where

xtype ='

pk'andname in(

select

name

from

sysindexes

where

indid in(

select

indid

from

sysindexkeys

where

id =

syscolumns.id

andcolid

=syscolumns.colid)))

then'√

'else

''end

as主鍵

from

syscolumns

inner

join

sysobjects

onsysobjects.id

=syscolumns.id

inner

join

systypes

onsyscolumns.xtype

=systypes.xtype

left

outer

join

sysproperties properties

onsyscolumns.id

=properties.id

andsyscolumns.colid

=properties.smallid

left

outer

join

sysproperties

onsysobjects.id

=sysproperties.id

andsysproperties.smallid =0

left

outer

join

syscomments

onsyscolumns.cdefault

=syscomments.id

where

(sysobjects.xtype ='

u'

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

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

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...