22,209
社区成员
发帖
与我相关
我的任务
分享
select * into #a from
(
select 1 id,'1,2,3,4'QSDW
)a
select * into #b from
(
select 1 id,1 QSID
union all select 1,2
)a
select a.id,b.Col2
from (
select id,convert(xml,'<row><b>'+rtrim(replace(QSDW,',','</b><b>'))+'</b></row>') as Col2 from #a)a
outer apply (select Col2=C.v.value('.','nvarchar(100)') from a.COl2.nodes('/row/b')C(v))b
where b.col2 not in (select QSID from #b)
/*
id Col2
-----------
1 3
1 4
(2 行受影响)
*/