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

时间:2022-06-20 17:12:55

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