DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: sql to compare two tables

  1. #1
    Join Date
    Apr 2007
    Posts
    24

    sql to compare two tables

    Can someone please help with a sql that will compare two tables having same column name for a missing row?

    Tanks in advance

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    select * from table 1 minus select * from table 2

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by davey23uk
    select * from table1 minus select * from table2
    Support Dave but please be sure table2 is the one with the less rows.

    Query does full scan on table1 selecting * then, full scan on table2 taking out of the result set all matching rows.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  4. #4
    Join Date
    Mar 2002
    Location
    Manchester, England
    Posts
    202
    if there is a unique column you can just do the minus on that as it'll be faster

Posting Permissions

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


Click Here to Expand Forum to Full Width