title: How to use multiple CHARINDEX function in SQL Server?
body: <p>I have the following code that it will extract the string before comma (","):</p>
  
  <pre><code>SELECT LTRIM(LEFT(@Adresa, CHARINDEX(',', @Adresa)-1))
  </code></pre>
  
  <p>Sometimes, comma (',') isn't the character I need to look after because it might be missing. Is there any way to adapt this query in order to look after comma and another value if comma is not found? If it is found, to finish the statement and not to look after the next one. Thanks!</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Text to be evaluated: My Address, no. 23. </p>
  
  <p>In some cases, the comma is missing by user mistake and the above code is giving me an error. If the comma is missing, I would like to go next and try to find "no.".</p>