码迷,mamicode.com
首页 > 数据库 > 详细

查看数据库所有表的所有字段

时间:2015-09-15 09:24:04      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:

select sysobjects.name as tbName,

syscolumns.name as colName,(case  when  (CHARINDEX(‘char‘, type_name(syscolumns.xtype))>0) then ‘(‘+type_name(syscolumns.xtype)+‘(‘+str(length,3)+‘)‘+‘,‘+(case syscolumns.isnullable when 0 then ‘not null‘ else ‘null‘ end) +‘)‘ else ‘(‘+type_name(syscolumns.xtype)+‘,‘+(case syscolumns.isnullable when 0 then ‘not null‘ else ‘null‘ end) +‘)‘  end) as colType from sysobjects left join syscolumns on syscolumns.id=object_id(sysobjects.name) where  sysobjects.xtype=‘U‘ order by sysobjects.name

技术分享

查看数据库所有表的所有字段

标签:

原文地址:http://www.cnblogs.com/viaiu/p/4809190.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!