title: Splitting a variable length column in SQL server safely
body: <p>I have a column (varchar400) in the following form in an SQL table : </p>
  
  <pre><code>Info
  UserID=1123456,ItemID=6685642
  </code></pre>
  
  <p>The column is created via our point of sale application, and so I cannot do the normal thing of simply splitting it into two columns as this would cause an obscene amount of work. My problem is that this column is used to store attributes of products in our database, and so while I am only concerned with UserID and ItemID, there may be superfluous information stored here, for example : </p>
  
  <pre><code>   Info
     IrrelevantID=666,UserID=123124,AnotherIrrelevantID=1232342,ItemID=1213124.
  </code></pre>
  
  <p>What I want to retrieve is simply two columns, with no error given if neither of these attributes exists in the <code>Info</code> column. : </p>
  
  <pre><code>UserID ItemID
  123124 1213124
  </code></pre>
  
  <p>Would it be possible to do this effectively, with error checking, given that the length of the IDs are all variable, but all of the attributes are comma-separated and follow a uniform style (i.e "UserID=number").</p>
  
  <p>Can anyone tell me the best way of dealing with my problem ?</p>
  
  <p>Thanks a lot.</p>