从两个备用 sql 语句写入 temp table

Write into temp table from two alternate sql statements

我想根据条件将两个查询的输出写入 table。我有这条查询但不起作用。请指教

DECLARE @promptflag varchar(1) = 'N'; 
DECLARE @pool varchar(10) = 'PJMRTO';


IF Object_id('tempdb..#pnode') IS NOT NULL 
DROP TABLE #pnode;

select
    case when @promptflag='Y' then 
    (select distinct YES_PNODE from PRICE_NODES where ISO = @pool and Biddable='Y')
        when @promptflag='N' then
    (select distinct YES_PNODE from PRICE_NODES where ISO = @pool and Biddable='Y' and NonPrompt_Node='Y')
    end

进入#pnode

思路更像这样:

select distinct YES_PNODE
into #pnode 
from PRICE_NODES
where ISO = @pool and Biddable = 'Y' and
      (@promptflag = 'Y' or  NonPrompt_Node = 'Y');

or 表达式只是您查询逻辑的缩写。