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 anonymous 13.12.2018 / 14:04

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)
    
13.12.2018 / 14:07