select
c.name as 字段名,
isnull(g.[value],'') as 备注
from
syscolumns c,sysproperties p
where
c.id = object_id('表名')
and
c.id=p.id and c.colid=p.smallid
c.name as 字段名,
isnull(g.[value],'') as 备注
from
syscolumns c,sysproperties p
where
c.id = object_id('表名')
and
c.id=p.id and c.colid=p.smallid
declare @sql varchar(8000)
set @tname='xxx'
set @sql=''select @sql=@sql+','+c.name+' as ['+isnull(g.[value],c.name)+']' from syscolumns c,sysproperties p where c.id = object_id(@tname) and c.id=p.id and c.colid=p.smallid
order by c.colidset @sql='select '+stuff(@sql,1,1,'')+' from '+@tnameprint @sqlexec(@sql)