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'字段說明'
--into ##tx
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 object_name(a.id),a.colorder
sql server中查詢資料庫中有哪些表
系統表sysobjects儲存的都是資料庫物件,其中type表示各種物件的型別,具體包括 u 使用者表 s 系統表 c check 約束 d 預設值或 default 約束 f foreign key 約束 l 日誌 fn 標量函式 if 內嵌表函式 p 儲存過程 pk primary key 約束...
查詢資料庫中有多少張表
sql server 2005 select from sysobjects where xtype u 查詢當前資料庫 下所有使用者建立的表 xtype char 2 物件型別。可以是下列物件型別中的一種 c check 約束 d 預設值或 default 約束 f foreign key 約束 ...
sql server 查詢資料庫中有多少個表
select from sysobjects where xtype u select from sysobjects where xtype u select from sysobjects where xtype c select from sysobjects where xtype d se...