title: Split string in SQL Server's xquery
body: <p>Is there a way to do something like the (unsupported) xquery tokenize in SQL Server?</p>
  
  <p>I have:</p>
  
  <pre><code>&lt;WITS:foo&gt;
   &lt;WITS:bars&gt;
    &lt;bar details="name=theName;value=theValue" other="false" stuff="true"&gt;
    &lt;/bar&gt;
   &lt;/WITS:bars&gt;
   &lt;WITS:bars notThis="oneIdontwant"&gt;
    &lt;bar&gt;&lt;/bar&gt;
   &lt;/WITS:bars&gt;
  &lt;/WITS:foo&gt;
  </code></pre>
  
  <p>and I want to pull out <code>theName</code>. The closest I have been able to come is to get <code>name=theName;value=theValue</code> via </p>
  
  <pre><code>SELECT
   x.query('
    distinct-values(
     for $name in data(//WITS:foo/WITS:bars[not (@notThis)]/WITS:bar[@details="name"))
     return $name
    )'
  )
  FROM (SELECT CAST(xmlColumn AS XML) x FROM blah Where blahblah) y
  </code></pre>
  
  <p>So far it looks like I'm out of luck since this is all running on SQL Server 2005, and from <a href="http://msdn.microsoft.com/en-US/library/ms178064%28v=sql.90%29.aspx" rel="nofollow">msdn</a> it seems like the only thing there is to work with strings is the four functions listed (no index-of, or other options).</p>
  
  <p>Right now I'm parsing after the fact, but I was wondering if there are any other ways I could get this done server side.</p>