Compare Columns

  • I have 3 columns of TabA to comapre with similar table TabB. How do i check if every record is same which may also has nulls where in count matches in both tables.

    How can i use EXCEPT in this scenario.

  • Could you provide us with the DDL for the tables, sample data for the tables (in a readily consummable format that we can cut, paste, and execute in SSMS), the expected results based on the sample data, and the code you have already written in an attempt to solve your problem.

    If you need help with this, please read the first article I reference below in my signature block.

  • something like this where in all the Code column in one server is char(5) and the other is varchar(5)

    select h3.code1,h3.code2,h3.code3,h6.code1,h6.code2,h6.code3

    from hock3.obever.emp h3 inner join

    hock6.obever.emp h6

    where h3.code1h6.code1 or

    h3.code2h6.code2 or

    h3.code3h6.code3

  • Tara (6/8/2009)


    something like this where in all the Code column in one server is char(5) and the other is varchar(5)

    select h3.code1,h3.code2,h3.code3,h6.code1,h6.code2,h6.code3

    from hock3.obever.emp h3 inner join

    hock6.obever.emp h6

    where h3.code1h6.code1 or

    h3.code2h6.code2 or

    h3.code3h6.code3

    This isn't what I asked from you. Doesn't really help me help you. As you probably have found, the where clause won't catch those records where a column value is null.

    Can we try again? Please provide us with what I requested. You will get much better answers along with tested code.

  • sample data

    Code1 Code 2 Code3

    865986239354

    865986239354

    865986239354

    NULL NULl NULL

  • and what is your expected output?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • every record of TabA and TabB should match.

  • Tara (6/8/2009)


    sample data

    Code1 Code 2 Code3

    865986239354

    865986239354

    865986239354

    NULL NULl NULL

    First, can't cut, paste, and execute the above to load the data into tables. Second, no DDL for the tables to create them to be loaded.

    Please, read the first article I have referenced below in my signature block.

Viewing 8 posts - 1 through 7 (of 7 total)

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