We help IT Professionals succeed at work.

question about best practice of Update query on MS Access local table and SQL serever linked table..

Medium Priority
197 Views
Last Modified: 2013-11-17
We have update queries in the system designed using the query grid,
where the data from a local MS Access table is set to update it to the sqlserver linked table.
I am curious to know which would be the best method

a) whether to use join in the update query like below and not having the where clause since join is already set on the ids belonging to both tables

UPDATE [Children-local] INNER JOIN Children ON [Children-local].childid = Children.childid SET Children.firstname = [Children-local].firstname, Children.middlename = [children-local].middlename, Children.lastname = [children-local].lastname;

2) Or to use the update query without setting the joins but specify the where clause criteria
like below
UPDATE Children, [Children-local] SET Children.firstname = [Children-local].firstname, Children.middlename = [children-local].middlename, Children.lastname = [children-local].lastname
WHERE (((Children.childid)=[children-local].[childid]));


Would the peformance matter if you are using join vs where clause and which is the best method.

Comment
Watch Question

Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
From a performance perspective, there is probably no difference. The query parser will determine the execution plan used, and in the case of identical queries - with the exception of Joins vs Where - the server will almost certainly use the same execution plan for both.

So it comes down to a matter of syntax preference. Many people have difficulties deciphering Join clauses (myself included), and prefer the Where approach ...

Author

Commented:
Is it true that using the joins the query needs to process more - to make sure and check the related
records from two sides hence it takes longer as supposed to just using a where clause.
Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
No. As I indicated earlier, the server will build an "execution plan" based on the tables, fields, indexes etc etc ... in the case of otherwise identical queries, except one uses Joins while the other uses Where, the server will almost certainly generate the same execution plan, which means that the server will do exactly the same thing. Of course, there is no guarantee of this.

That said, there are opposing schools of thought on this. Some firmly believe you should use Joins at all times, others think that Joins are resource intensive, etc etc ... if you search for this topic, you'll find intense debates and rhetoric on both sides of the battle.

There is a definite art to building good queries, and the only way to determine if a query is better off with a Where clause or a Join (if at all) is to build it both ways and then time both.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.