Compare two tables in SQL server 2005 and get whats changed in two tables.

  • Hi all,

    I have two almost similiar tables in sql server (Table1 has more columns and Table2 has few less columns) for each incoming record from Table1 I want to compare whether there is any change in data by comparing each column to column. Even if there is one change in one column out of 10 columns I want to insert that record into some other Table 3. I want to run a query to compare those two tables and to find out those rows that are not common. here are the columns for the two tables

    Table 1

    id,

    name,

    address1,

    state,

    telno,

    zipcode,

    test1,

    test2,

    test3

    Table 2

    id,

    name,

    address1,

    state,

    telno,

    zipcode

    There are just few columns in the table and there are more than 75 columns which are in common.

    In one row everything could be similiar except the tel no, in some other row everything could be similiar except the zip code. how do i run a query to figure out which row is not similiar.

    Your help would be appreciated.

    Thanks,

    Sai

  • Please don't cross post. It just wastes peoples time and fragments replies.

    No replies to this thread please. Direct replies to: http://qa.sqlservercentral.com/Forums/Topic740627-338-1.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hi,

    I have a same similar problem and I got the content from google and I just copied the content and added my own version to it.

    Thanks,

    sai

  • Hi Gila,

    Please let me know if I need to post a new topic for my problem or not.

    Thanks,

    Sai

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

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