select
(case when a.colorder=1 then d.name else '' end) n'表名',
a.colorder n'字段序號',
a.name n'欄位名',
(case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end) n'標識',
(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) n'主鍵',
b.name n'型別',
a.length n'占用位元組數',
columnproperty(a.id,a.name,'precision') as n'長度',
isnull(columnproperty(a.id,a.name,'scale'),0) as n'小數字數',
(case when a.isnullable=1 then '√'else '' end) n'允許空',
isnull(e.text,'') n'預設值',
isnull(g.[value],'') as n'字段說明'
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.**allid
where
d.name = '**' --要查詢的表
order by
object_name(a.id), a.colorder
通過SYSPROCESSES表得到資料庫的死鎖資訊
sysprocesses sysprocesses 表中儲存關於執行在 microsoft sql server 上的程序的資訊。這些程序可以是客戶端程序或系統程序。sysprocesses 只儲存在 master 資料庫中。列名 資料型別 描述 spid smallint sql server 程...
筆記 得到Access資料庫中的所有表名
今晚幫乙個朋友做點東西,需要得到access資料庫中的所有表名,經過一番研究後終於搞定這個函式,感覺還是有點意思,特將其做個筆記儲存下來 返回mdb資料庫中所有表表名 public string getshematablename string database path,string databa...
匯出資料庫中的所有表的結構
使用下面的儲存過程 如果輸入表名則取出此表,如果不輸入表名則選出全表結構,有問題請繼續問我。此儲存過程可以取出所輸入表的字段資訊,如果表名為空則列出當前資料庫中的所有表的資訊,如果 withview引數不為0則列出檢視的字段資訊,為0則不列檢視資訊 create procedure dbo tabl...