title: T-SQL - Remove everything before and after in a string
body: <p>Please assist me with the SQL query shown below.</p>
  
  <p>This is the error I get:</p>
  
  <blockquote>
    <p>System.Exception: TransformerException ---> Library.Utilities.TransformerException: Transformer transforming [00000000000<strong>85153227</strong>:documentId] using [4:transformId] with time remaining [00:00:54.4517645:TimeSpan] output document is [0000000000085153231:documentId] ---> and so on...</p>
  </blockquote>
  
  <p>I'm training to retrieve this value 85153227 only.</p>
  
  <p>Please assist</p>
  
  <pre><code>SELECT  
      SUBSTRING(message, 0, CHARINDEX('System.Exception', message)) + ' ' +  
      CASE          
         WHEN CHARINDEX('Transformer transforming [', message) &gt; 0
            THEN SUBSTRING(message, CHARINDEX('[',message), LEN(message)-CHARINDEX('[', message)) 
            ELSE '' 
      END
  FROM
      dbo.Documents 
  </code></pre>
  
  <p>Thank you</p>