title: Converting regex_substr and listagg code over to SQL Server
body: <p>I'm looking for a bit of help. I'm converting something over from Oracle to SQL Server, and am in a pickle.</p>
  
  <pre><code>select distinct
      field1, field2, 
      regexp_substr(path, '[^/]+', 1, column_value) elem
  from 
      grouped,
      table(cast(multiset(select level from dual
                          connect by level &lt;= regexp_count(path,'/')) as sys.odciNumberList))
                          where regexp_substr(path, '[^/]+', 1, column_value) is not null),
       result as (
         select field1, field2,
                dense_rank()
                 over (order by listagg(elem,',') within group (order by elem))
                  grp
        from split
        group by field1, field2
  </code></pre>
  
  <p>I'm under the impression that using the STUFF function would be a likely alternative to the <code>listagg()</code> function, but in order to get that far I need to figure out how to convert the <code>regex_substr()</code> code over to SQL Server 2012.</p>
  
  <p>The sample data :</p>
  
  <pre><code>field1      field2
  --------------------------------
  02598559  | /04460516
  04355059  | /04460576/05339398
  04352043  | /04461255
  --------------------------------
  </code></pre>
  
  <p>What's the best way to tackle this?</p>