0

I am performing the following operation:

Update A set A.col1 = B.col1
From LinkedServer.LinkedDatabase.dbo.remoteTable A
JOIN #localTempTable B on B.column = A.primaryKeyColumn

The performance is terrible and the query takes what seems to be forever, given that i can't just create a table to store the temp table data in, what can I do in SQL Server 2014 to improve this? I am considering running the query from the linked server instead.

Tom V
15.8k7 gold badges66 silver badges87 bronze badges
asked Mar 15, 2016 at 18:58
0

1 Answer 1

1

current query

Update linked 
 set linked.col1 = local.col1
 From LinkedServer.LinkedDatabase.dbo.remoteTable linked
 JOIN #localTempTable local 
 on local.column = linked.primaryKeyColumn 

It is typically better to perform the write operation locally
Here you are both reading from and writing to the linked server

My recommendation is if you are going to create #localTempTable then do so on LinkedServer. Have a session on the LinkedServer and link to local to populate #localTempTable but #localTempTable is now on LinkedServer. Flop the link.

insert into #linkedLocalTempTable 
select ... 
from Local.LinkedDatabase...

Please post the query to populate #localTempTable
If you use that table for other stuff then flopping stuff around may not be and option

answered Mar 15, 2016 at 20:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.