Data

  • Hi,

    I am trying to compare two columns but looks like its a data issue

    One column as data like "Team Leader - XYZ" and second one has "Team Leader-XYZ"

    Is there a way to clean either one within the query so I can do a comparison?

  • sharonsql2013 (12/22/2015)


    Hi,

    I am trying to compare two columns but looks like its a data issue

    One column as data like "Team Leader - XYZ" and second one has "Team Leader-XYZ"

    Is there a way to clean either one within the query so I can do a comparison?

    Quick thought, you could possibly remove the spaces in both columns for the comparison, not going to be too efficient though.

    😎

    Check out this thread for an efficient way to clean the character values if you have more complex requirements than simply remove the spaces.

    Edit: added link.

  • Eirikur Eiriksson (12/22/2015)


    Quick thought, you could possibly remove the spaces in both columns for the comparison, not going to be too efficient though.

    ... unless you add persisted computed columns to both tables that remove the whitespace.

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

  • Jeff Moden (12/22/2015)


    Eirikur Eiriksson (12/22/2015)


    Quick thought, you could possibly remove the spaces in both columns for the comparison, not going to be too efficient though.

    ... unless you add persisted computed columns to both tables that remove the whitespace.

    Yet again you beat me to it Jeff;-)

    😎

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

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