Re: Violation of primary key
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Sun, 30 Mar 2008 08:27:26 +0000 (UTC)
Zamdrist (zamdrist@xxxxxxxxx) writes:
As far as using NOT EXISTS vs. the Left Outer Join syntax...isn't this
more a matter of style than correctness? In a Left Outer Join the two
fields in the destination would be NULL as the source records are not
found in the destination table. I understand NOT EXISTS also works,
but I'm inclined to believe that using JOINs are more efficient.
It's indeed matter of style and expressiveness than correctness.
As for efficient, you can never tell before you benchmark the query at hand.
If the optimizer does it right, you should get the same plan in both cases
anyway.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- References:
- Violation of primary key
- From: Zamdrist
- Re: Violation of primary key
- From: Erland Sommarskog
- Re: Violation of primary key
- From: Zamdrist
- Violation of primary key
- Prev by Date: Re: Violation of primary key
- Next by Date: Re: SQL Server 2005 disk layout - opinions?
- Previous by thread: Re: Violation of primary key
- Next by thread: How to Interrogate SQL Server Tables for Specific Values - Here's how to do it in MS Access
- Index(es):
Relevant Pages
|