列出SQL SERVER數(shù)據(jù)庫所有表信息的SQL語句
作者:佚名 
  SQL語句可以實(shí)現(xiàn)許多的功能,下文介紹的是列出SQL SERVER數(shù)據(jù)庫所有表信息的SQL語句,如果您有興趣的話,不妨一看。
 下面為您介紹的是列出SQL SERVER 數(shù)據(jù)庫所有表信息的SQL語句,該SQL語句供您參考,希望對您學(xué)習(xí)SQL語句能有所啟迪。
- select
 - ( case when a.colorder = 1 then d.name else '' end ) 表名,
 - a.colorder 字段序號,
 - a.name 字段名,
 - ( case when COLUMNPROPERTY (a.id,a.name,'isidentity') = 1 then '√' else '' end ) 標(biāo)識
 - ( 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 類型,
 - a.length 字節(jié)數(shù),
 - COLUMNPROPERTY ( a.id,a.name ,'PRECISION' ) as 長度,
 - 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 字段說明
 - 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é)任編輯:段燃 
                    來源:
                    互聯(lián)網(wǎng)
 














 
 
 
 
 
 
 