0

I now have a different problem ( see previous question).

The string I have is One/Two/Three/Four/Five

I need to extract after the third / and before the fourth /. The added advantage is that the characters up until the third / are all the same length in the column. I am using -

SUBSTRING (ORGPATHTXT,20,(CHARINDEX('/',(ORGPATHTXT))))

But this is still including some text after the 4th / but only passing upto 11 character into the column, which I'm finding very strange.

gotqn
  • 37,902
  • 44
  • 152
  • 231

1 Answers1

0

There is a third argument to CHARINDEX which indicates the position to start the search. You can use it.

SUBSTRING(ORGPATHTXT,20,CHARINDEX('/',ORGPATHTXT,20)-20)

20 here is the first position after the 3rd / in the string.

Vamsi Prabhala
  • 47,581
  • 4
  • 34
  • 53