Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find position of last occurrence of character

Status
Not open for further replies.

JayKusch

MIS
Oct 30, 2001
3,199
US
Say I have a string of:

R:\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\model.mdf

and I want to know the position of the last \ (which would be position 43).

Thanks!

Thanks

J. Kusch
 
Code:
Declare @Test VarChar(100)


Set @Test = 'R:\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\model.mdf'

Select Len(@Test) - CharIndex('\', Reverse(@Test))


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top