I have two strings, I want to get difference between contents of two strings in SQL ??
for example,
Declare @String1 as varchar(100)=\'a,b,c,d,e\';
First take the function from the following link Parse comma-separated string to make IN List of strings in the Where clause
Then use the following query;
Declare @String1 as varchar(100)='a,b,c,d,e';
Declare @String2 as varchar(100)='b,e';
SELECT
s1.val
,s2.val
FROM [dbo].[f_split](@String1,',') s1
FULL OUTER JOIN [dbo].[f_split](@String2,',') s2
ON s1.val = s2.val
WHERE s1.val IS NULL
OR s2.val IS NULL
Which will give you the following results;
val val
a NULL
c NULL
d NULL