select * into #lsb from 表1
while exsts(select top(1)* from #lsb where ....)
begin
if not exsts(select ... from 表2 where ...)
insert into 表2(....) select ...from #lsb
detele #lsb where .....
end
create proc test
as
if .....--检查表#tb是否存在
.....
insert into #tb(列)
exec 存储过程B
insert into tb
select * from #tb a where not exists (select 1 from tb b where a.主键=b.主键)