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
Vijaya Kadiyala
SSCrazy Eights
Points: 9119
More actions
April 8, 2009 at 8:04 am
#974314
Ramesh (4/8/2009)Or this way too...DECLARE @SomeFile VARCHAR(255)SET @SomeFile = 'C:\WINDOWS\system32\FileName.xls'SELECT RIGHT( @SomeFile, CHARINDEX( '\', REVERSE( @SomeFile ) + '\' ) - 1 )
Ramesh (4/8/2009)
DECLARE @SomeFile VARCHAR(255)
SET @SomeFile = 'C:\WINDOWS\system32\FileName.xls'
SELECT RIGHT( @SomeFile, CHARINDEX( '\', REVERSE( @SomeFile ) + '\' ) - 1 )
Perfect solution..with simple trick using REVERSE...