Bas (nomailplease) writes:[color=blue]
> This is usually faster by the way, I use it a lot:
>
> SELECT Tracking.TCode FROM TaskCode RIGHT OUTER JOIN
> Tracking ON TaskCode.TCode = Tracking.TCode
> WHERE TaskCode.TCode IS NULL[/color]
Maybe it was in SQL 6.5. I would not expect so in SQL 2000. These two
queries have very similar query plans:
select * from Northwind..Customers c
where not exists (select * from
Northwind..Orders o where o.CustomerID = c.CustomerID)
select c.*
FROM Northwind..Customers c
LEFT JOIN Northwind..Orders o on c.CustomerID = o.CustomerID
WHERE o.OrderID IS NULL
But the latter has a extra filter step the first query don't need.
I advice against using outer joins for NOT EXISTS queries. NOT EXISTS
more clearly expresses what you are after. Another advantage to use
NOT EXISTS is that does require you to know what is LEFT and RIGHT.
--
Erland Sommarskog, SQL Server MVP,
sommar@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp