If you want rows where none of the words overlap, you can use a not exists
clause:
select t.*
from t
where not exists (select 1
from string_split(t.col1, ' ') s1 join
string_split(t.col2, ' ') s2
on s1.value = s2.value
);
Note: This formulation allows you to return the entire row -- that is, other columns that are not included in the comparison.
If you are using an older version of SQL Server that does not support string_split()
, I would suggest finding the code for a user-defined function that does the same thing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…