Compare Data between two table

  • hi

    i need script or function or procedure to get field's name has data difference and get this data

    which the tables have same fields

    Example:

    tableA

    code name sector

    1 Jone 1

    tableB

    code name sector

    1 Jone 3

    gave me

    field is sector

    data tableA's filed 1

    data tableB's filed 3

  • can you have multiple people called Jone in your tables? if so is the code the same in tableA and tableB for the right name?

    SELECT

    A.Code,

    A.Name,

    A.Sector,

    B.Sector

    FROM

    tableA A

    INNER JOIN

    tableB B

    ON

    A.Code = B.Code

    AND

    A.Name = B.Name

    WHERE

    A.Sector <> B.Sector

  • thanks for help me

    i need to know this field only but

    this table contain more from one field

    Example1:

    tableA

    code name sector department

    1 Jone 1 10

    tableB

    code name sector department

    1 Jone 1 30

    get field department only

    Example2:

    tableA

    code name sector department

    1 Jone 1 10

    tableB

    code name sector department

    1 Jone 3 40

    get fields sector and department only

  • hello Dear,

    you can use AppexSQLLog for Compare data in 2 table and find difference beteen.

    Best Regards,

    zohreh

  • thanks zohreh

    but i will use this script in my project (exe)

  • SQL Server has a TABLEDIFF.exe that you may use to compare objects, check BOL for more info

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 6 posts - 1 through 5 (of 5 total)

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