declare @sql nvarchar(4000),@table_name nvarchar(100)
set @table_name='tbl_mail_info'------------------你库里面的表名字、视图名字、存储过程等
set @sql=''
select @sql=@sql+' ,'+name+'
' from syscolumns
where id = (select id from sysobjects where name=@table_name)
order by colorder
set @sql=stuff(@sql,1,7,'select ')+'from '+@table_name
print @sql
---------------------------------结果
select mail_type
,mail_subject
,mail_body
from tbl_mail_info