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