Showing posts with label somedate. Show all posts
Showing posts with label somedate. Show all posts

Friday, March 23, 2012

Remote Update takes forever

I have a SQL 2005 & SQL 2000 server. I am attempting to execute a simple update statement, something that looks like:

update AD

set AD.SomeDate = getdate()

from [ServerX].DB.dbo.Table

where ColumnX = 'X'

ServerX is the SQL 2000 box.

ServerY is the SQL 2005 box. Server Y is where this statement is invoked from. (Not shown in statement).

I have a linked server set up.

When executed from the 2000 box, it runs in < 1 second.

When both environments are 2005 to 2005, it takes less than < 1 second.

Try using OPENQUERY to perform the update - I've provided an (untested) example below.

http://msdn2.microsoft.com/en-us/library/ms188427.aspx

Chris


Code Snippet

--Note: Untested so you may need to play around with the syntax. Execute on Server Y.
UPDATE OPENQUERY(ServerX, 'SELECT SomeDate FROM DB.dbo.Table WHERE ColumnX = ''X''')
SET SomeDate = GETDATE()