I've been trying to write a Table-Valued function that takes value pairs as a parameter and return a table with two columns.
Below is the function signature I am trying to do.
FUNCTION [dbo].[ValuePairParser]( @DelimitedValuePairs VARCHAR(MAX),
@Delimiter CHAR(1),
@ValuePairDelimiter CHAR(1) )
RETURNS @ValuePairTable
TABLE ( Id INT, Code INT )
I want to call the method like below
@ValuePairs VARCHAR(MAX) = '1:1, 1:2, 1:4, 2:3, 1000:230, 130:120,'
ValuePairParser (@ValuePairs, ',', ':')
Can you see any nice way to split above ValuePairs sting and create a table with two columns?