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

2015-11-21 01:40:57 · 作者: · 浏览: 2
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