This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Check the below input String and expected output String for finding the last SET of String after Specific Character
Input string:
1 |
rerc-poiq-xxxx |
Required output string:
1 |
xxxx |
Solution 1:
1 2 3 |
DECLARE @str varchar(100) SET @str = 'rerc-poiq-xxxx' SELECT RIGHT(@str, CHARINDEX('-', REVERSE(@str)) - 1) |
Solution 2:
1 2 3 4 5 6 7 8 9 10 |
;with cte as ( select *, row_number() over (order by (select null)) as rownum from string_split('rerc-poiq-xxxx','-') ) select top 1 value from cte order by rownum desc |
Please try the different solution for this puzzle and share it via comment...