列出SQL SERVER數(shù)據(jù)庫(kù)所有表信息的SQL語(yǔ)句
作者:佚名
SQL語(yǔ)句可以實(shí)現(xiàn)許多的功能,下文介紹的是列出SQL SERVER數(shù)據(jù)庫(kù)所有表信息的SQL語(yǔ)句,如果您有興趣的話,不妨一看。
下面為您介紹的是列出SQL SERVER 數(shù)據(jù)庫(kù)所有表信息的SQL語(yǔ)句,該SQL語(yǔ)句供您參考,希望對(duì)您學(xué)習(xí)SQL語(yǔ)句能有所啟迪。
- select
- ( case when a.colorder = 1 then d.name else '' end ) 表名,
- a.colorder 字段序號(hào),
- a.name 字段名,
- ( case when COLUMNPROPERTY (a.id,a.name,'isidentity') = 1 then '√' else '' end ) 標(biāo)識(shí)
- ( case when (
- select count(*) from sysobjects
- where name in (
- select name from sysindexes
- where (id = a.id ) and ( indid in
- (select indid from sysindexkeys where
- ( id = a.id ) and ( colid in (
- select colid from syscolumns
- where ( id = a.id ) and ( name = a.name ))))))
- and ( xtype ='PK')) > 0 then '√' else '' end ) 主鍵,
- b.name 類(lèi)型,
- a.length 字節(jié)數(shù),
- COLUMNPROPERTY ( a.id,a.name ,'PRECISION' ) as 長(zhǎng)度,
- isnull ( COLUMNPROPERTY ( a.id,a.name ,'Scale'),0) as 小數(shù)位數(shù),
- (case when a.isnullable = 1 then '√' else '' end ) 允許空,
- isnull ( e.text,'') 默認(rèn)值,
- isnull (g.[value],'' ) as 字段說(shuō)明
- from syscolumns a left join systypes b
- on a.xtype = b.xusertype
- inner join sysobjects d
- on a.id = d.id and d.xtype='U' and d.name <> 'dtproperties'
- left join syscomments e
- on a.cdefault = e.id
- left join sysproperties g
- on a.id = g.id and a.colid = g.smallid
- order by a.id ,a.colorder
【編輯推薦】
責(zé)任編輯:段燃
來(lái)源:
互聯(lián)網(wǎng)