So this can easily be done in SQL.
But since this is string parsing it will be intense on the sql server. So i recommend to rather change the way the data are received.
But if you want to attempt in doing this in sql
here you go:
declare @String varchar(50) = 'CHILD=1625=0n=1==3&ADULT=1900=1j=1==1'
/*
-- Get the text left of the first =
select left(@String,charindex('=',@String,1)-1)
--get the first index of the &
select charindex('&',@String)
-- get the first index of the first = after the first &
select charindex('=',@String,charindex('&',@String))
-- Get the text between the first & and only look at the amount of char to return.
-- First & index + 1The amount of char to return
select SUBSTRING(@String,charindex('&',@String)+1, charindex('=',@String,charindex('&',@String))-charindex('&',@String)-1)
*/
select left(@String,charindex('=',@String,1)-1)+', '+ SUBSTRING(@String,charindex('&',@String)+1,charindex('=',@String,charindex('&',@String))-charindex('&',@String)-1)
I have added some small select statements so you can see what each step is trying to do.
Hope this helps
--------------------------------------------------------------------------------------------------------------------------------------------------------
To some it may look best but to others it might be the worst, but then again to some it might be the worst but to others the best.
http://www.sql-sa.co.za