SQL資料字典

2021-04-23 06:45:14 字數 1722 閱讀 1499

set ansi_nulls on

set quoted_identifier on

goalter procedure [dbo].[proc_dataselect]

@tabelname varchar(100)

asselect

-- tablename=o.name,

fieldid=c.colid,

fieldname=c.name,

fielddescription=isnull(pfd.value,''),

fieldtype=quotename(t.name)

+case

when t.name in (n'decimal',n'numeric')

then n'('+cast(c.prec as varchar)+n','+cast(c.scale as varchar)+n')'

when t.name=n'float'

or t.name like n'%char'

or t.name like n'%binary'

then n'('+cast(c.prec as varchar)+n')'

else n'' end

+case when c.isnullable=1 then n'' else n' not' end+n' null',

defilelength=c.length,

isidentity=columnproperty(o.id,c.name,n'isidentity'),

isprimarykey=case when opk.xtype is null then 0 else 1 end,

tabledescription=isnull(ptb.value,n'')

from sysobjects o

join syscolumns c

on c.id=o.id

and objectproperty(o.id,n'isusertable')=1

join systypes t

on t.xusertype=c.xusertype

left join syscomments df

on df.id=c.cdefault

left join sys.extended_properties ptb

on ptb.major_id =o.id and ptb.minor_id=0

left join sys.extended_properties pfd

on pfd.major_id =o.id and pfd.minor_id=c.colid

left join sysindexkeys idxk

on idxk.id=o.id

and idxk.colid=c.colid

left join sysindexes idx

on idx.indid=idxk.indid

and idx.id=idxk.id

and idx.indid not in(0,255)

left join sysobjects opk

on opk.parent_obj=o.id

and opk.name=idx.name

and objectproperty(opk.id,n'isprimarykey')=1

where o.name=@tabelname

order by o.name,c.colid

資料字典生成sql

select 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end,字段序號 a.colorder,欄位名 a.name,標識 case when ...

SQL 匯出資料字典

用於參考 select 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end,字段序號 a.colorder,欄位名 a.name,主鍵 case ...

資料字典的匯出sql語句

select c.table name 表明,t.table comment 表備註,c.column name 列名,c.column type 資料型別,c.data type 字段型別,c.character maximum length 長度,c.is nullable 是否為空,c.col...