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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the CHARINDEX of last occurrance.

Status
Not open for further replies.

woogoo

Programmer
Feb 14, 2004
247
GB
Hi All,

I need to find the charindex() of the last occurrance of a character within string, but this is proving awkward to solve can anyone help here?
--

woogoo
 
reverse the string, get the charindex and subtract from the length of the string. Like this:

Code:
Declare @Test VarChar(20)

Set @Test = '123456789101112'

Select Len(@Test) - CharIndex('1', 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