comparision

  • Hi,

    I have a table with column name is

    proposaldata

    123456

    542213

    and other table column is

    proposaldata

    000123456

    000542213

    so i need to compare to this columns of different table s but 123456 and 000123456 should treated as same so wat i will do

  • karunakar2351 (9/4/2013)


    Hi,

    I have a table with column name is

    proposaldata

    123456

    542213

    and other table column is

    proposaldata

    000123456

    000542213

    so i need to compare to this columns of different table s but 123456 and 000123456 should treated as same so wat i will do

    If the data are always numeric you can match them by converting them to integers. Something like:

    SELECT table1.proposaldata

    , table2.proposaldata

    FROM table1

    INNER JOIN table2

    ON CONVERT(int, table1. proposaldata) = CONVERT(int, table2. proposaldata)

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • what if the value if out of range of INT?

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • kapil_kk (9/4/2013)


    what if the value if out of range of INT?

    Then you have the BIGINT datatype 😛

    But if this method is correct or not, depends on the data in the tables. We don't know more then the sample data provided. So my solution works with these sample data. I don't make any assumption about the real data. These could be character values and hence cannot even be converted to INT.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **

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

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