Data Difference between 2 structurally identical tables

  • Hi
    I have 2 tables A and B.Both are same structurally but have different records.Now i want to know the records in A but not in B.
     
    Following is what i have already tried :
     
    a) Usage of set operator (select * from A - Select * from B) --- Giving Access Violation
    b) Usage of | operator(select a1|a2 from A where a1|a2 not in (select a1|a2 from B)
        a1,a2 is the unique key defined on both the tables. --- Gives invalid operator for datatype.This works in Oracle.
     
     
    Regards
    Poonam
  • This should work, although I haven't tested it

    Select * FROM A LEFT OUTER JOIN B ON A.a1=B.a1 AND A.a2=B.a2 WHERE B.a1 IS NULL AND B.a2 IS NULL

    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

Viewing 2 posts - 1 through 1 (of 1 total)

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