Wednesday, March 28, 2012

OpenQuery - Execution plan

Whats the best way to run some dynamic sql when using OpenQuery on a linked
server? Is it possible to use sp_executesql in OpenQuery?
Ben
See if this helps you
DECLARE @.tablename AS SYSNAME
SET @.tablename = 'pubs..authors'
EXECUTE ('SELECT * FROM OPENQUERY([servername], ''SELECT * FROM ' +
@.tablename + ''') AS T')
"Ben UK" <BenUK@.discussions.microsoft.com> wrote in message
news:E6724190-2A1D-4FCB-A6E5-18A8F312D6E6@.microsoft.com...
> Whats the best way to run some dynamic sql when using OpenQuery on a
> linked
> server? Is it possible to use sp_executesql in OpenQuery?
sql

No comments:

Post a Comment