return the right char in sql code example
Example 1: sql right characters
-- For Oracle only
-- syntax
SUBSTR(<main-string>,-<number-of-characters>)
-- example
SUBSTR('Useless stuff',-9) -- OUTPUT: ess stuff
-- practical example
SELECT SUBSTR('Useless stuff',-9)
FROM DUAL;
Example 2: reading from right to left from string find first special characters in sql
DECLARE @strvalue varchar(20) = 'SDADH/SDKDS/SD/UIO-123/WEA/456'
SELECT REVERSE(SUBSTRING(REVERSE(@strvalue),0,CHARINDEX ('/',REVERSE(@strvalue))))