首页 > 开发 > 综合 > 正文

显示数据库中所有表及其信息

2024-07-21 02:06:33
字体:
来源:转载
供稿:网友

alter procedure dbo.storedprocedure1
as
 select   (case when columnproperty( ss.id,ss.name,'isidentity')=1 then '1'else '0' end) n'标识',(case when (select count(*) from sysobjects where (name in (select name from sysindexes where (id = ss.id) and (indid in (select indid from sysindexkeys where (id = ss.id) and (colid in (select colid from syscolumns where (id = ss.id) and (name = ss.name))))))) and (xtype = 'pk'))>0 then '1' else '0' end) n'主键',ss.colorder n'字段序号', (case when ss.isnullable=1 then '1'else '0' end) n'允许空', s.name as n'表名',ss.name as n'字段名' ,t.name as n'数据类型' , isnull(columnproperty(ss.id,ss.name,'scale'),0) as n'小数位数', ss.length n'占用字节数', isnull(e.text,'') n'默认值', columnproperty(ss.id,ss.name,'precision') as n'长度',g.[value] as n'字段描述' from sysobjects s left join syscolumns ss on ss.id=s.id inner join systypes t on ( t.xtype=ss.xtype and t.name<>'sysname') inner join sysproperties g on (ss.id=g.id and ss.colid = g.smallid) inner join sysindexkeys sk on (sk.id=ss.id and sk.colid=1)  left join syscomments e
on ss.cdefault=e.id where s.xtype='u' and s.name<>'dtproperties'
 return
--by huntfox
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表