title: Parse an SQL record to select varying number of fields?
body: <p>I am using Microsoft SQL Server Management Studio and I have a database that contains records. I want to run a query on those records and produce individual rows based on the parsing of the record - however if the unparsed string is contains a 01 I need to produce I row and if it contains 02 I need to produce 2 rows.</p>
  
  <p>The data is like this:</p>
  
  <pre><code>01AAAA
  01BBBB
  02CCCCDDDD
  02CCCCAAAA
  01BBBB
  02BBBBDDDD
  01AAAA
  </code></pre>
  
  <p>and I want the following after my select statements:</p>
  
  <pre><code>AAAA
  BBBB
  CCCC
  DDDD
  CCCC
  AAAA
  BBBB
  BBBB
  DDDD
  AAAA
  </code></pre>
  
  <p>Is this possible using select and some kind of IF statements, or do I need to split the data into another table. Thanks.</p>