SQL 如果不存在,我如何添加多个数据?

SQL How could i add MULTIPLE DATA from an if not exist?

我有一个 table 超过 1500 条记录,我想插入另一个 table 不包含 @Cot_NomArr = 'PAGO' 的数据,我想插入的记录是变量@Cot_Credit table 看起来像:

ABCOTIZA
-------------------------
Cot_Credit | Cot_NomArr
-------------------------
5459892698 | DEBT
3649949499 | DEBT
6265662645 | PAGO
6265662645 | PAGO
6565626569 | DEBT

所以按照我的查询:

create table #TESTINT(
    Cre_Numero  varchar(15) 
)

select * from ABCOTIZA

DROP TABLE #TESTINT

/* VARIABLES*/
declare @Cot_Credit varchar(15)
/* CONSTANTES*/
declare @Cot_NomArr varchar(150)
/* DECLARACIÓN DE CONSTANTE*/
select  @Cot_NomArr = 'PAGO'

select @Cot_Credit = isnull(Cot_Credit,''),
       @Cot_NomArr = isnull(Cot_NomArr,'')
      from ABCOTIZA noholdlock  

if not exists (select distinct(Cot_Credit) from ABCOTIZA where Cot_Credit = @Cot_Credit and Cot_NomArr = @Cot_NomArr) begin
    insert into #TESTINT(Cre_Numero)
        values (@Cot_Credit)
end

select * from #TESTINT

我想要我的 table #TESTINT 最后看起来像:

#TESTINT
----------------
@Cot_Credit
----------------
5459892698
3649949499
6565626569

因为那些是 Cot_NomArr

中没有 'PAGO' 的那些

我正在使用 ASE Sybase

但是不工作,它没有插入任何数据...请帮助。

这是你想要的吗?

insert into #TESTINT (Cre_Numero)
    select a.Cre_Numero
    from ABCOTIZA a
    where a.Cot_NomArr <> 'Pago';