Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pull sums from 2 tables
Message
From
16/10/2007 11:19:44
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01261037
Message ID:
01261261
Views:
15
Sergey,

To your question on this...
SELECT * FROM mytable mt1
  WHERE NOT EXISTS (SELECT * FROM mytable WHERE id = mt1.id)
SQL 2005 now implements the ANSI EXCEPT (and INTERSECT) operators...
SELECT Vendor.VendorID  FROM Purchasing.Vendor Vendor 
   EXCEPT
        SELECT VendorID FROM Purchasing.PurchaseOrderHeader POHeader
I've read posts where people implemented EXCEPT and gained some increase in performance, though others have said that performance is about about the same and that the execution plans are about the same (maybe the first group did some additional refactoring).

But either way, since you brought up readability, I think you'd agree that EXCEPT is even simpler code! ;)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform