Using a paramter in OPENQUERY | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Using a paramter in OPENQUERY

We have a pair of linked SQL servers that are experiencing performance issues on doing an update. OPENQUERY seems like the way to go, but we’ve got a parameter in our command, and are getting an error when trying to prepare the variable. Looks like the error is being reported by the remote server. Does anyone know how to do this? Here is an example. declare @x as nvarchar(30)
set @x = ‘R042151-998028’ UPDATE
openquery(efrontoffice, "select * from
eFRONTOFFICE.clientele73.db:confused:rdItem WHERE uItemRef= @x" )
SET changedate=GETDATE()
Errors:
Server: Msg 8180, Level 16, State 1, Line 3
Statement(s) could not be prepared.
Server: Msg 137, Level 15, State 1, Line 3
Must declare the variable ‘@x’.
Never mind…found the answer…. http://www.sqlmag.com/forums/messageview.cfm?catid=8&threadid=9121
]]>