Seeking advise on the diff

  • Greetings,

    I need your expertise on my issue. I do two tables, each has only one simple column (varchar(500) type). Also, each table has roughly about 4 million rows. What is the best way to write a query that show rows in tableA are not in tableB?

    Your guidance or sample query is truly appreciated.

    john9569

    MSSQL server 2008

  • john9569 (8/10/2011)


    Greetings,

    I need your expertise on my issue. I do two tables, each has only one simple column (varchar(500) type). Also, each table has roughly about 4 million rows. What is the best way to write a query that show rows in tableA are not in tableB?

    Your guidance or sample query is truly appreciated.

    john9569

    MSSQL server 2008

    Look up INTERSECT in Books On-line.

  • This was removed by the editor as SPAM

  • stewartc-708166 (8/11/2011)


    To find items in tableA that do not exist in tableB, use EXCEPT

    Sorry, your right. Must learn to go to bed when tired.

  • Why not to use simple old LEFT JOIN:

    SELECT a.OneColumn

    FROM TableA AS a

    LEFT JOIN TableB AS b ON b.OneColumn = a.OneColumn

    WHERE b.OneColumn IS NULL

    I do assume that there are no rows with NULL values...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

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

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