title: SQL substract string using SUBSTRING and CHARINDEX
body: <p>I have the following string:</p>
  
  <pre><code>'{Mapi-Reply-Recipient-Smtp-Proxies=, Mapi-Non-Receipt-Notification-Requested=true, Message-ID=&lt;6a2k4081-f6134-4345c-b232429-a32410de78@abd.local.test.global&gt;, Authentication-Results=vadmzmail2342.test.com'
  </code></pre>
  
  <p>and I would like to extract ONLY the MessageID part: </p>
  
  <pre><code>&lt;6a2k4081-f6134-4345c-b232429-a32410de78@abd.local.test.global&gt;
  </code></pre>
  
  <p>I've tried unsuccessfully to use substring and charindex functions:</p>
  
  <pre><code>   SELECT SUBSTRING('{Mapi-Reply-Recipient-Smtp-Proxies=, Mapi-Non-Receipt-Notification-Requested=true, Message-ID=&lt;6a2k4081-f6134-4345c-b232429-a32410de78@abd.local.test.global&gt;, Authentication-Results=vadmzmail2342.test.com',
     (SELECT CHARINDEX(' Message-ID=&lt;','{Mapi-Reply-Recipient-Smtp-Proxies=, Mapi-Non-Receipt-Notification-Requested=true, Message-ID=&lt;6a2k4081-f6134-4345c-b232429-a32410de78@abd.local.test.global&gt;, Authentication-Results=vadmzmail2342.test.com')),
     (SELECT CHARINDEX('&gt;, Authentication-Results', '{Mapi-Reply-Recipient-Smtp-Proxies=, Mapi-Non-Receipt-Notification-Requested=true, Message-ID=&lt;6a2k4081-f6134-4345c-b232429-a32410de78@abd.local.test.global&gt;, Authentication-Results=vadmzmail2342.test.com')))
  </code></pre>
  
  <p>and the result to my query is:</p>
  
  <pre><code> Message-ID=&lt;6a2k4081-f6134-4345c-b232429-a32410de78@abd.local.test.global&gt;, Authentication-Results=vadmzmail2342.test.com
  </code></pre>
  
  <p>What I am doing wrong?? </p>