Re: OPENQUERY UPDATE Syntax help needed



(rshivaraman@xxxxxxxxx) writes:
I am updating a local table based on inner join between local table
and remote table.

Update LocalTable
SET Field1 = B.Field1
FROM LinkedServer.dbname.dbo.RemoteTable B
INNER JOIN LocalTable A
ON B.Field2 = A.Field2
AND B.Field3 = A.Field3

This query takes 18 minutes to run.
I am hoping to speed up the process by writing in OPENQUERY syntax.

UPDATE LocalTable
SET Field1 = B.Field1
FROM OPENQUERY(LINKEDSERVER,
'SELECT Field1, Field2, Field3 FROM dbname.dbo.RemoteTable) B
INNER JOIN LocalTable A
ON B.Field2 = A.Field2
AND B.Field3 = A.Field3

I would not really expect this to perform better.

Distributed queries are always difficult, but it's difficult to suggest
anything without further knowledge about the table. How big are the
two tables?


--
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
.



Relevant Pages

  • Re: sql server mgmt studio "Login failed for user x", "Error Number 18
    ... and i know the username/pwd supplied by the hosting company is ... I can log into the remote DB via VS2005 using those credentials no ... If I login in to a local DB from within Sql Server Mgmt studio, ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.tools)
  • Re: cant open database on remote sql server 2000 by sa
    ... Could you post the exact error message you get? ... to the remote server from your PHP application, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: Service stop/start/restart questions 2005 SP2
    ... -SQLS Surface Area Configuration ... There is a recommendation that you should not start/stop SQL Server ... are greyed out on a remote client. ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: How do I link a database in SQL
    ... You can set up a linked server. ... sp_addlinkedsrvlogin to specify how you are to connect to the remote server. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Query training -- Complex queries
    ... > Update PositionsEOM ... Here you don't have a derived table, but a correlated subquery. ... UPDATE in Books Online. ... is not written for SQL Server. ...
    (microsoft.public.sqlserver.server)