declare mmp cursor for select * from #a open mmp /*建立cursor与查询数据的关联*/ declare @a1 varchar(50),@a2 varchar(50),@a3 varchar(50),@a4 varchar(100),@a5 varchar(50) declare @cnt int select @cnt=0 fetch next from mmp into @a1 while (@@fetch_status=0)--检查是否读取到数据 begin if @cnt=1 fetch next from mmp into @a2 if @cnt=2 fetch next from mmp into @a3 if @cnt=3 fetch next from mmp into @a4 if @cnt=4 fetch next from mmp into @a5 set @cnt=@cnt+1 end close mmp