I am trying to find the last occurence of a character within a string. I have the following code: what is the easiest way to accomplish this?
SELECT CASE WHEN FieldA IS NULL THEN '' ELSE
set @pos = charindex('\',FieldA,@pos)
SUBSTRING(FieldA ,@pos + 1, LEN(FieldA) - (@pos + 1)) END AS FileUploaded
Example data of FieldA : "DirectoryA\DirectoryB\DirectoryC\FileName"