Extracting text from a longer string

  • I have a field called ReportPath containing data like this:

    /DL047 London Ship Managers/Call Records Invoice Back Up

    /DL047 London Ship Managers/Invoices by Vessel

     

    How do I create and alias to get just the left-most text between the two "\" characters so it returns just

    DL047 London Ship Managers

    DL047 London Ship Managers

     

    Anyone able to help an amateur?  Thanks in advance...

  • Do all the entries look like this or some have the slash and others do not

  • SUBSTRING([ReportPath],2,CHARINDEX('/',[ReportPath],2)-2)

    Is the first '/' always in column 1 ?

    Far away is close at hand in the images of elsewhere.
    Anon.

  • If not then

    SUBSTRING([ReportPath],CHARINDEX('/',[ReportPath])+1,CHARINDEX('/',[ReportPath],CHARINDEX('/',[ReportPath])+1)-CHARINDEX('/',[ReportPath])-1)

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply