What is best way to get last indexof character in SQL 2008

sql, sql-server-2008, string

Solution

A little tricky, but you could do something like:

REVERSE(SUBSTRING(REVERSE([field]),0,CHARINDEX('[char]',REVERSE([field]))))

Problem

In C#, we have `String.LastIndexOf` method to get a last index of a particular character location for given string. Is there any similar function to do same in SQL Server. I tried using `CHARINDEX` but couldn't able to achieve it.

Original source

Related problems