-- 若#temp不存在
select * into #temp from
(
select 'A' as [Name], count(1)as [Value] from A
union all
select 'B' as [Name], count(1)as [Value] from B
)t
-- 若#temp已存在
insert into #temp
select 'A', count(1) from A
union all
select 'B', count(1) from B
用游标试试啊