select o.name as tablename,
user_name(o.uid) as owner,
isnull(ptb.value,n' ') as tabledescription,
c.colid as fieldid,
c.name as fieldname,
quotename(t.name)
+case
when t.name in (n'decimal ',n'numeric ')
then n'( '+cast(c.prec as varchar)+n', '+cast(c.scale as varchar)+n') '
when t.name=n'float '
or t.name like n'%char '
or t.name like n'%binary '
then n'( '+cast(c.prec as varchar)+n') '
else n' ' end
+case when c.isnullable=1 then n' ' else n' not ' end+n' null ' as fieldtype,
isnull(pfd.value, ' ' ) as fielddescription,
c.length as defilelength,
isnull(df.text,n' ') as fielddefault,
case columnproperty(o.id,c.name,n'isidentity ') when 1 then '√' else '' end as isidentity,
case columnproperty(o.id,c.name,n'iscomputed ') when 1 then '√' else '' end as iscomputed,
case columnproperty(o.id,c.name,n'isrowguidcol ') when 1 then '√' else '' end as isrowguid,
case when opk.xtype is null then '' else '√' end as isprimarykey
from sysobjects o
join syscolumns c
on c.id=o.id
and objectproperty(o.id,n'isusertable ')=1
join systypes t
on t.xusertype=c.xusertype
left join syscomments df
on df.id=c.cdefault
left join sysproperties ptb
on ptb.id=o.id and ptb.**allid=0
left join sysproperties pfd
on pfd.id=o.id and pfd.**allid=c.colid
left join sysindexkeys idxk
on idxk.id=o.id
and idxk.colid=c.colid
left join sysindexes idx
on idx.indid=idxk.indid
and idx.id=idxk.id
and idx.indid not in(0,255)
left join sysobjects opk
on opk.parent_obj=o.id
and opk.name=idx.name
and objectproperty(opk.id,n'isprimarykey ')=1
order by o.name,c.colid
sqlserver刪除所有的使用者表
create procedure dbo.deletetable as declare name as nvarchar 128 declare curobject cursor for select name from sysobjects where type u and name like p...
sql server 查詢資料庫所有的表名 字段
執行一條sql語句 select from information schema.columns where table name subject 表名 1.利用 sysobjects 系統表 在這個表中,在資料庫中建立的每個物件 例如約束 預設值 日誌 規則以及儲存過程 都有對應一行,我們在該表中...
sql server 查詢資料庫所有的表名 字段
執行一條sql語句 select from information schema.columns where table name subject 表名 1.利用 sysobjects 系統表 在這個表中,在資料庫中建立的每個物件 例如約束 預設值 日誌 規則以及儲存過程 都有對應一行,我們在該表中...