title: insert multiple records from a single record
body: <p>I need to insert multiple records into a table based on multiple values found in a single text field retrieved from a select statement. Currently I am using an <code>INSERT INTO and SELECT</code> statement where by each record in the select statement forces an <code>INSERT INTO</code>. However, I need to be able to insert multiple records, as opposed to 1, based on multiple values I parse out of a string of text. Here's bascially what I need to do:</p>
  
  <pre><code>INSERT INTO tableA
  Select personid, name, contacts, status
  </code></pre>
  
  <ul>
  <li>Parse contacts</li>
  <li>Determine the number of contacts in the string (see contacts string below)</li>
  <li>Insert 1 record per contact. </li>
  </ul>
  
  <p>The logic should be something like this:</p>
  
  <pre><code>do while
  insert
  end
  
  From tableB
  </code></pre>
  
  <p>The contacts field is <code>varchar</code>, and can have 3 different contacts listed in the field as follows:</p>
  
  <pre><code>contacts = 'Jim phone 333-222-1111, John 777-888-9999, Joe 444-555-6666"
  </code></pre>
  
  <p>I need to insert a record for each contact listed in the string - <code>Jim, John, and Joe</code>.
  I'm having trouble clearly explaining this so please let me know if more information is required.</p>
  
  <p>I'm using MS SQL 2012.</p>