Skip to content
Advertisement

Reverse to STRING_AGG

Here is a sample data on which we are further processing.

My question is, is there any exact reverse of the STRING_AGG function for SQL Server?

Like I am merging using STRING_AGG with the following code

I need to reverse the process but I had to use CURSOR so I am searching for an alternative solution.

Below is the cursor code for better understanding the purpose.

Advertisement

Answer

There is similar string_split is available which can be used, e.g.

for each string_agg using cross apply we can convert them back to rows,

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement