troubleshooting Question

Potential Issue with UPDATE FROM??

Avatar of D B
D BFlag for United States of America asked on
Microsoft SQL ServerSQL
8 Comments1 Solution97 ViewsLast Modified:
I recall back in the SQL Server 2000 days, this was considered bad and inefficient coding. Does it still hold true:

SET b.something = a.something
FROM table1 a
INNER JOIN table2 b
ON a.key = b.key

The issue is that the UPDATE statement is updating table2 but table1 is in the FROM clause, and it could cause issues with performance and should be written:

SET b.something = a.something
FROM table2 b
INNER JOIN table1 a
ON a.key = b.key

Could there be performance issues in newer versions (e.g. 2012 and up) with this syntax? If so, can someone explain how the inefficiencies show themselves? I've looked as some query plans going both ways and they seem identical.
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros