I have entered data into my SQL server. I want to remove all the characters before a hyphen. There are different amounts of characters before the "-".
For Example:
ABC-123
AB-424
ABCD-53214
I want this result:
123
424
53214
I am new to SQL Server and really need help.
Thank You in advance.
Try this:
right(MyColumn, len(MyColumn) - charindex('-', MyColumn))
Charindex finds the location of the hyphen, len finds the length of the whole string, and right returns the specified number of characters from the right of the string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With