Any suggestion on below:
I need to compare two strings which have comma separated ISO Country codes.
For example : String1 = '356,840'
String2 = '840,356'
Actually both string give same countries but if we do SQL compare they are not same.
Is there anyway or any inbuilt SQL function which fits here.
Note : I don't want to use table variable/Temp table due to some xyz constraints.
you could do it with the DelimitedSplit8K function for examplehttp://www.sqlservercentral.com/articles/Tally+Table/72993/
DECLARE @String1 varchar(30) = '356,840',
@String2 varchar(30) = '840,356'
IF NOT EXISTS(
SELECT fn.Item from dbo.DelimitedSplit8K(@String1,',') fn
SELECT fn.Item from dbo.DelimitedSplit8K(@String2,',') fn
PRINT 'No Differences found'
PRINT 'they are not the same, regardless of order'
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!