I want to split below one input parameter in stored procedure
<code>@input varchar(Max)= '1~100~101~103,2~200~201~203,3~300~301~303, 4~400~401~403'
</code>
<code>@input varchar(Max)= '1~100~101~103,2~200~201~203,3~300~301~303, 4~400~401~403'
</code>
@input varchar(Max)= '1~100~101~103,2~200~201~203,3~300~301~303, 4~400~401~403'
I want to get it as shown here:
<code>1 100
1 101
1 103
2 200
2 201
2 203
3 300
3 301
3 303
4 400
4 401
4 403
</code>
<code>1 100
1 101
1 103
2 200
2 201
2 203
3 300
3 301
3 303
4 400
4 401
4 403
</code>
1 100
1 101
1 103
2 200
2 201
2 203
3 300
3 301
3 303
4 400
4 401
4 403
New contributor
Krishna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I would recommend creating a table valued function that uses STRING_SPLIT to split first the ‘,’ loop over the result, split the ‘~’, second loop. There might be more elegant ways though.