Symptoms
You have been given a list of values in a SQL table and wish to extract the alpha prefix, e.g. "INV123, CASE001, TICKET99" -> "INV, CASE, TICKET"
Cause
n/a
Resolution
SELECT col, CASE WHEN col LIKE '[A-Z]%' THEN LEFT(col, PATINDEX('%[^A-Za-z]%', col) - 1) ELSE '' END AS alpha_prefix FROM table
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article