代码改变世界

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

2015-09-15 08:55  只喝牛奶的杀手  阅读(408)  评论(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