On mysql we have the substring_index function:
SUBSTRING_INDEX(str,delim,count)
Definition: Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.
I´ve found only created functions on sql server that works with positive count parameter like on this Stackoverflow topic:
SQL Server equivalent of substring_index function in MySQL
I need a function that works with the negative count. I will show some examples from what i need:
1)SUBSTRING_INDEX('AAA/BBB/CCC','/',-1) Result expected: CCC
2)SUBSTRING_INDEX('CCC','/',-1) Result expected: CCC
Does anyone know a function that i can create on sql server that implements this negative count like MySQL?
Thanks.