Need Suggestion on How to work on Parsename command with dot or decimal?

  • Hello,

    I need to divide the fields into four parts. Right now, parsename command is working 95% of my data.

    Example of the data are separated by the > sign.

    1. Service > Systems > Solution > Vendor Management

    2. Insurance > Business > Performance > Version 3.0

    SQL command to obtain the last part:

    PARSENAME(REPLACE(field1, ' > ', '.'), 1)

    When running the query with the select statement, I got the 'Vendor Management' on the first one and the NULL value on the second result.

    I believe it is due to the value has a 'dot' in there.

    I tried to search for solutions from this page and I still cannot get it to work.

    Anyone has suggestions? Thanks.

  • Simply replace the periods with something else before replacing the greater than sign with a period. It's up to you whether you restore the periods after the PARSENAME.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Or use a real splitter.

    --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)

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

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