恰恰相反,这种情况不能使用合并,而是拆分
with roy as
(select [dw]=cast(left([dw],charindex(',',[dw]+',')-1) as nvarchar(100)),Split=cast(stuff([dw]+',',1,charindex(',',[dw]+','),'') as nvarchar(100)) from [表A]
union all
select [dw]=cast(left(Split,charindex(',',Split)-1) as nvarchar(100)),Split= cast(stuff(Split,1,charindex(',',Split),'') as nvarchar(100)) from Roy where split>''
)
select * from [表B] where [_Identify] in (select [dw] from roy ) option (MAXRECURSION 0)