现在的位置: 首页 > 综合 > 正文

怎样获取一个表中所有字段的信息

2012年02月02日 ⁄ 综合 ⁄ 共 415字 ⁄ 字号 评论关闭

Create view fielddesc
  as
  select o.name as table_name,c.name as field_name,t.name as type,c.length as
  length,c.isnullable as isnullable,convert(varchar(30),p.value) as desp
  from syscolumns c
  join systypes t on c.xtype = t.xusertype
  join sysobjects o on o.id=c.id

--这个表操作在SQL2005中不存在
  left join sysproperties p on p.smallid=c.colid and p.id=o.id
  where o.xtype='U'
  查询时:
  Select * from fielddesc where table_name = '你的表名'

附:获取数据库所有对象
Select * From SysObjects

抱歉!评论已关闭.