title: T-SQL query to get the string between two special characters
body: <p>I wanted to extract a word between two special characters. I tried to use the trim and substring functions but the results aren't the expected one.</p>
  
  <p>Input: </p>
  
  <pre><code>viewpointops\Leslie.cullum.7M5 
  </code></pre>
  
  <p>Output needed: </p>
  
  <pre><code>Leslie.cullum
  </code></pre>
  
  <p>I tried <code>select SUBSTRING(c2,0,CHARINDEX('\',c2))</code> from table used this query to save viewpointops\ in a variable and similarly for the rest of the inputs. It was a long query and not an efficient one as well.</p>
  
  <p>Thanks in advance.</p>