执行以下正常
select FItemID into #tab from t_ICItem t1
left join t_SubMessage t2 on t1.FPlanTrategy = t2.FInterID
where t2.FID = 'MPS' and t2.FTypeID = 167
执行以下语句不正常
while exists (
select w1.FItemID
from ICBom w1
inner join (
select u1.FInterID
from ICBomChild u1
inner join #tab v1 on u1.FItemID = v1.FItemID
union
select u1.FInterID
from ICCustBomChild u1
inner join #tab v1 on u1.FItemID = v1.FItemID ) x1 on w1.FInterID = x1.FInterID
where w1.FStatus = 1 and w1.FUseStatus = 1072
and w1.FItemID not in (select FItemID from #tab)
)
insert into #tab
select distinct w1.FItemID
from ICBom w1
inner join (
select u1.FInterID
from ICBomChild u1
inner join #tab v1 on u1.FItemID = v1.FItemID
union
select u1.FInterID
from ICCustBomChild u1
inner join #tab v1 on u1.FItemID = v1.FItemID ) x1 on w1.FInterID = x1.FInterID
where w1.FStatus = 1 and w1.FUseStatus = 1072
and w1.FItemID not in (select FItemID from #tab)
就是将查询出来的数据insert to 到#tab 表时不正常,但查询的结果是0行,也就是0行insert into 到#tab 表.