title: Use of CHARINDEX and SUBSTRING to get a substring between brackets from a string
body: <p>The expression I'd need is that but it fails ('Command has been aborted') because of the '-1'. But without this '-1' it gives me one character too many.</p>
  
  <blockquote>
    <p>select
    SUBSTRING(M_COMMENT,CHARINDEX('[',M_COMMENT)+1,CHARINDEX(']',M_COMMENT)
    - CHARINDEX('[',M_COMMENT)-1) from TRN_EODA_DBF</p>
  </blockquote>
  
  <p>But it works fine with the '+1' which I don't understand.</p>
  
  <blockquote>
    <p>select
    SUBSTRING(M_COMMENT,CHARINDEX('[',M_COMMENT)+1,CHARINDEX(']',M_COMMENT)
    - CHARINDEX('[',M_COMMENT)+1) from TRN_EODA_DBF</p>
  </blockquote>
  
  <p>Thanks for your help.</p>