title: How to split string and insert values into table in SQL Server
body: <p>I have a string like this:</p>
  
  <pre><code>72594206916,2,1/2/08,Tacoma,WA:72594221856,5,5/7/13,San Francisco,CA:72594221871,99,12/30/12,Dallas,TX
  </code></pre>
  
  <p>This is basically 5 values in each of 3 rows (from an ASP.NET grid). I need to split this string apart into 5 columns and 3 rows in a SQL Server table. Individual values are separated by commas and rows by colons.</p>
  
  <p>I found a function to split a string into pieces and I can get the rows out of this string:</p>
  
  <pre><code>declare @testString varchar(100)
  set @testString = '72594206916,2,1/2/08,Tacoma,WA:72594221856,5,5/7/13,San Francisco,CA:72594221871,99,12/30/12,Dallas,TX'
  
  select *
  from dbo.SplitString(@testString, ':')
  </code></pre>
  
  <p>gives me:</p>
  
  <pre><code>72594206916,2,1/2/08,Tacoma,WA
  72594221856,5,5/7/13,San Francisco,CA
  72594221871,99,12/30/12,Dallas,TX
  </code></pre>
  
  <p>This gives me a result set with the three rows (the function outputs a table). Can I call this function again at the same time and insert its output into a table somehow?</p>