Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pull sums from 2 tables
Message
De
16/10/2007 11:19:44
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01261037
Message ID:
01261261
Vues:
16
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! ;)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform