浩浩 [程序人生]

     时光在一行行代码中悄然流逝。。。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

select sysobjects.name as "表名",syscolumns.name as "字段名",
case when systypes.name in ('binary','char','nchar') then (systypes.name + '(' + cast(syscolumns.prec as varchar(50)) + ')')
when systypes.name in ('decimal','numeric') then (systypes.name + '(' + cast(syscolumns.prec as varchar(50)) + ',' + cast(syscolumns.scale as varchar(50)) + ')')
when systypes.name in ('nvarchar','varchar','varbinary') then (case when syscolumns.prec = -1 then (systypes.name + '(MAX)') else (systypes.name + '(' + cast(syscolumns.prec as varchar(50)) + ')') end)
else systypes.name end as "字段类型",
syscomments.text as "默认值", case when syscolumns.isnullable = 1 then 'Y' else 'N' end as "能否为空",
cast(sys.extended_properties.value as varchar(1024)) as "备注"
from syscolumns inner join systypes on syscolumns.xtype = systypes.xtype left join sysobjects
on syscolumns.id = sysobjects.id left outer join sys.extended_properties
on ( sys.extended_properties.minor_id = syscolumns.colid and sys.extended_properties.major_id = syscolumns.id) left outer join syscomments
on syscolumns.cdefault = syscomments.id where syscolumns.id in (select id from sysobjects where xtype = 'u') and (systypes.name <> 'sysname') order by sysobjects.name asc

posted on 2009-08-14 15:28  paul001  阅读(316)  评论(0编辑  收藏  举报