SQL Charindex and SUbstring
<p>I'm trying to figure out how to extract the <code>AccountNumber</code> on one of my columns with below sample value:</p>

<pre><code>&gt;&lt;AccountNumber&gt;12345678&lt;/AccountNumber&gt;&lt;Links&gt;http://test@test123.com
</code></pre>

<p>the string length before and after the account number varies. </p>

<p>I have tried below code but the i cant figure out how to just extract the <code>AccountNumber</code>. Even the account number has different lengths.</p>

<pre><code>Select  substring(XmlData,
                   charindex('&gt;&lt;AccountNuber',XMLData),
                 50 )
   from Item with(nolock)
</code></pre>