How to return the last value of an sql string?


I need to use the last character of a string G. How do I get it with sql server?

SET @VALOR = '0000050529-G'

I want to get the letter G

asked by Felipe Michael da Fonseca 13.12.2018 в 14:04

1 answer


Use the function RIGHT() it returns the N character (s) to the right, the amount is informed by the second argument.

SET @VALOR = RIGHT('0000050529-G', 1)
answered by 13.12.2018 в 14:07