Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Execution Plan ?

Author  Topic 

Ex
Posting Yak Master

166 Posts

Posted - 2004-12-28 : 17:03:24
Hello all this question is just out of interest

i ran the execution plan over these 2 update statements and found they are actually identical which kind of puzzled me
does the first update statement do a JOIN as well ? cause i would of though at least there would be some differences in the execution plan or maybe some speed differences

am i right in assuming in their implementation they are identical speed wise? or would there be a difference in speeds over a large enough data set?


1)
UPDATE a SET
myrow = i.myrow
FROM my_Table a, inserted i
WHERE
a.pk1= i.pk1 AND a.pk2 = i.pk2 AND
a.pk3 = i.pk3 AND dim.pk4 = i.pk4


2)
UPDATE a SET
myrow = i.myrow
FROM my_Table a
JOIN inserted i on
a.pk1= i.pk1 AND a.pk2 = i.pk2 AND
a.pk3 = i.pk3 AND dim.pk4 = i.pk4

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-12-28 : 17:06:30
Yes the first does a JOIN as well. One way is the ANSI way, the other is the T-SQL way. I find that the JOIN way is easier to read. They will perform the same.

Tara
Go to Top of Page

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2004-12-30 : 07:16:02
Neither of those queries are ANSI compliant.
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-12-30 : 12:34:04
Well, there is that. :) ANSI compliance doesn't support the aliased name of the table in the UPDATE. It can only be used in the FROM. blah, blah, blah

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -