sql 語句取得資料表演所有資訊

2021-04-22 02:53:08 字數 1086 閱讀 6584

select 

表名 = case when a.colorder=1 then d.name else '' end, 

--欄位序號=a.colorder, 

欄位名=a.name, 

字段說明=isnull(g.[value],''),

--標識=case when columnproperty(a.id,a.name,'isidentity')=1 then '√' else '' end, 

主鍵=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 = a.id and colid=a.colid  ))) 

then '√' else '' end, 

型別=b.name, 

--占用位元組數=a.length, 

長度=columnproperty(a.id,a.name,'precision'), 

小數字數=isnull(columnproperty(a.id,a.name,'scale'),0), 

允許為空=case when a.isnullable=1 then '√' else '' end, 

預設值=isnull(e.text,'')

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 d.name,a.id,a.colorder 

SQL語句 清除資料表的所有記錄

對資料庫進行清空,要求高效 快速。以下是比較有效的解決方法。truncate table name 還有乙個排重的sql解決方法 alter ignore table dict add unique index content 建乙個索引。truncate table truncate是sql中的乙...

取得sql2005 表字段資訊的sql語句

select row number over order by id as row number,fieldname,fielddescn as cnname,fieldtype,fieldlength,isidentifier,iskeyfield,allownull,defaultvalue,f...

ADO如何取得資料庫中表的字段資訊

若要取得資料庫中表的字段資訊,由以下recordset物件的屬性可得知 actualsize屬性 欄位的實際大小。definedsize屬性 定義欄位的大小。type屬性 字段型別,使用以下數字代表之 文字text 200 日期時間date 135 整數int 識別碼 3 單精準度 4 雙精準度 5...