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

how to return characters between two /'s 1

Status
Not open for further replies.

darwin101

Programmer
Mar 7, 2001
156
US
hi all

I am trying to return the characters between 2 /
where the field contains " /abc/defgh " i want 'abc'
i am able to remove the first/ but not the second and the characters to the left.
substring(field,charindex('/',field)+1 ,len(field))

any pointers would be appreciated
 
thanks that works great.

is it possiable to make this work if there is only one / in the field?
where @v = '/abcd '
 
got it, Thanks Denis
select case
when path like '/%/%' then
left(substring(path,charindex('/',path)+1 ,len(path)),charindex('/',substring(path,charindex('/',path)+1 ,len(path)))-1)
else substring(path,2,30)
end

from catalog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top