Dec 12, 2008 #1 woogoo Programmer Joined Feb 14, 2004 Messages 247 Location 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
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
Dec 12, 2008 #2 gmmastros Programmer Joined Feb 15, 2005 Messages 14,912 Location US 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 Upvote 0 Downvote
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