title: Get substring until a specific character starting from right to left SQL
body: <p>I have a string column where I need to find the substring until the first '-' is found.</p>
  
  <p>Example column ELOT-IGS-2. I need to get "2" as output.
  These columns come from a table so I cannot declare the variable as a fixed string.</p>
  
  <p>I tried <code>LOCATE</code>, <code>SUBSTRING_INDEX</code> but none are build in functions.</p>
  
  <p>I also tried <code>RIGHT(ID_BETSLIP,CHARINDEX('-',ID_BETSLIP)-1)</code> but this does not work when I have 2 times "-"</p>
  
  <p>Does anyone have an idea?</p>