Splitting a URL Using a Single Query

  • Hi,

    I would like to know how to separate a given URL into different parts like the given example below:

    http:\\www.google.co.in\asdfdf\asdfasf?as234=234

    fld1 fld2 fld3 fld4 fld5

    http:\\http://www.google.co.inasdfdfasdfasfas234=234

    Please help me to write a single query so that it will separate a given URL as shown.

    With Regards

    Dakshina Murthy

  • Last half of the following article tells you how to do a "split". Just replace the ? with a \ in the URL, remove the first 7 characters, and do the split.

    http://www.sqlservercentral.com/articles/TSQL/62867/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • If you really want it in a single query, create a function using the same technique. Your turn... why does it have to be in a single query?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • This is one situation where a CLR function would do the job nicely. It's got a nice URI object that exposes the various parts of a URL as properties - and if your parsing requirements are more complicated you can always use a RegEx...

    Regards,

    Jacob

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

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