先来邹建大大的
--下面是测试
--测试数据
declare @t table(列1 varchar(10))
insert into @t
select 'a'
union all select 'd'
union all select 'e'
union all select 't'
union all select 's'
union all select '5'
union all select '96'
--处理
declare @s varchar(8000),@i int
select @s='',@i=1
select @s=@s+',[列'+cast(@i as varchar)+']='''+列1+''''
,@i=@i+1
from @t
set @s=substring(@s,2,8000)
exec('select '+@s)
/*--测试结果
列1 列2 列3 列4 列5 列6 列7
---- ---- ---- ---- ---- ---- ----
a d e t s 5 96
--*/