How to return the last value of an sql string?

6

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
source

1 answer

9

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