34,576
社区成员
发帖
与我相关
我的任务
分享
把你那一堆数据放进一个表中
select * from ta t where not exists(select 1 from table where id=t.id)
--把这些数据插入临时表里
select b.*
from #tb b
where val not in (select distinct val from tb)
create table t1
(
col1 varchar(10)
)
insert into t1
select 'A' union all
select 'B' union all
select 'C' union all
select 'X' union all
select 'Y'
--已经存在的表,不用你创建
declare @abc table(col1 varchar(10)) --定义一个表变量
insert into @abc
select 'A' union all
select 'B' union all
select 'D' union all
select 'F'
select * from @abc where col1 not in (select col1 from t1)