获取一个表的所有字段:
declare @sql varchar(1000)
set @sql=''
select @sql=@sql+name+',' from syscolumns where id=(select id from sysobjects where name='tablename') order by colid
set @sql=left(@sql,len(@sql)-1)
print @sql
--实际应用时,需修改表名tablename