数据不多就直接放到临时表中,如:
declare @counts int
create table #temp(字段)
set @counts =0
while @counts <(select count(*) from 表)
begin
insert into #temp
select * from 表where各种条件
set @counts=@counts+1
end
select * from #temp
go
如果数据量较大,创建一个实体表,加上必要的索引以便查询
select * from A
UNION ALL
SELECT * FROM B
UNION ALL
SELECT * FROM C
???
select * from 结果集1
union
select * from 结果集2
union
select * from 结果集3
没看到楼上的回答,你的那个循环是死循环,永久执行,最起码得加一个 set @count=@count+1
不过你这个循环好像没啥意义。