Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010
    Posts
    1

    Post Unanswered: Unmatched Rows moved to another table

    Hi guys,

    I am sure I am making this harder than it has to be. I need to take two tables with identical fields and bump them against each other and have the results dump out into another table. I found the below SQL code and it comes up and gives me a message that the two tables do not match but I the rows that do not match to go into another table. In my example I only have one field but I need it to compare all fields. Even if it is just the row from the first table.

    Any help you can give would be appreciated. THANKS!


    Code:
    SELECT MIN(TableName) AS TableName, ID, COL1
    FROM 
    (
    SELECT 'CustProduction' as TableName, A.PRCHSR_SHRT_NM
    FROM CustProduction A
    UNION ALL
    SELECT 'Data_Entry_Master' as TableName, B.PurcSN
    FROM Data_Entry_Master B
    )  tmp
    GROUP BY ID, Col1, COL2, COL3
    HAVING COUNT(*) = 1
    ORDER BY ID

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •