我有一张保存付款数据的表。我想将以拒绝状态结束的订单插入#tmp_Declined。然后,我想将最初被拒绝但在使用替代付款方式时获得授权的付款插入 #tmp_Authorized。
我可以使用 2 个 select into 语句来做到这一点,其中 where 子句略有不同,但使用相同的基表。
我考虑了一个类似下面的例子:
select *
into #tmp_Declined
from Payments
except
select *
from Payments
where WasOrginallyDeclined = 1
and MostRecentPaymentAccepted = 1
Run Code Online (Sandbox Code Playgroud)
这种方法虽然仍然会在某个时间填充一个临时表。是否有保留字或查询“技巧”将插入#tmpA 中满足条件,然后插入#tmpB 中未插入#tmpA 中的任何内容?
我希望能够通过一个事务写入 2 个表。