Home Forums SQL Server 2005 T-SQL (SS2K5) Find last occurence of a character within a string RE: Find last occurence of a character within a string

  • Or this way too...

    DECLARE @SomeFile VARCHAR(255)

    SET @SomeFile = 'C:\WINDOWS\system32\FileName.xls'

    SELECT RIGHT( @SomeFile, CHARINDEX( '\', REVERSE( @SomeFile ) + '\' ) - 1 )

    --Ramesh