Update syntax for a remote table access


R

RTY

I have to update a remote database. I can't link to the tables because it
slows down my application to a crawl. So I just modified the SQL statements
to get to the remote database. The append was easy and the syntax works.
But, the Update statement doesn't. I need to use one table to update the
other. When I leave out the second table (tblOpportunityLocal) and all
references the statement will update the table correctly. How do I get the
SQL statement to accept both the remote table and local table references?
(and I can't use replication).

UPDATE tblOpportunityCollectionMaster in
'\\FILESHARES.CORP.XX.COM\Americas\Opportunity Collection Database\Master
Opportunity Collection Database V1.mdb', tblOpportunityLocal SET
tblOpportunityCollectionMaster.[Opportunity Name] =
tblOpportunityLocal.oppOpportunityName,
tblOpportunityCollectionMaster.Customer = "Test2",
tblOpportunityCollectionMaster.Project = "Test Project"
WHERE (((tblOpportunityCollectionMaster.[Work
Type])=tblOpportunityLocal.[oppWorkType]));
 
Ad

Advertisements

J

John W. Vinson

I have to update a remote database. I can't link to the tables because it
slows down my application to a crawl. So I just modified the SQL statements
to get to the remote database. The append was easy and the syntax works.
But, the Update statement doesn't. I need to use one table to update the
other. When I leave out the second table (tblOpportunityLocal) and all
references the statement will update the table correctly. How do I get the
SQL statement to accept both the remote table and local table references?
(and I can't use replication).

You will need an explicit join between the tables: something like

UPDATE tblOpportunityCollectionMaster in
'\\FILESHARES.CORP.XX.COM\Americas\Opportunity Collection Database\Master
Opportunity Collection Database V1.mdb' INNER JOIN tblOpportunityLocal
ON tblOpportunityCollectionMaster.joinfield = tblOpportunityLocal.joinfield
SET
tblOpportunityCollectionMaster.[Opportunity Name] =
tblOpportunityLocal.oppOpportunityName,
tblOpportunityCollectionMaster.Customer = "Test2",
tblOpportunityCollectionMaster.Project = "Test Project"
WHERE (((tblOpportunityCollectionMaster.[Work
Type])=tblOpportunityLocal.[oppWorkType]));

I presume there is some field (which I called joinfield) which identifies
which record in Master should be updated by which record in Local.

If this is truly a *remote* (over a WAN rather than a Local Area Network)
database, you may be putting both the local and the remote database at risk of
corruption. Access isn't really designed to work over a WAN, and a dropped
connection during the execution of your query could irreversibly damage your
database! KEEP GOOD BACKUPS, and see if there is some other way to get the
data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top