SQL Server - select substring of all characters after last hyphen
I am working with a product database trying to extract the product color from a combined ID / color code column where the color code is always the string following the last hyphen in the column. The problem is that the number of hyphens, product ID and color code may be different.
Here are four examples:
ABC123-001 BCD45678-0165 S-XYZ999-M2235 A-S-ABC123-001
The color in this case, the codes will be 001
, 0165
, M2235
and 001
. What would be the best way to select them in your column?
+3
source to share