August 24, 2007 at 11:13 am
Execute statements run under a different context, and table variables are not shared. You could try using a temporary table.
Regards,
Andras
August 24, 2007 at 11:16 am
Also see http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=149&messageid=393025
Regards,
Andras
August 24, 2007 at 12:13 pm
Why does this need to be dynamic SQL? I don't see anything in your code that would require dynamic SQL to accomplish.
August 24, 2007 at 3:13 pm
John, thanks for your reply. I've simplified the query significantly to focus on the part that's causing the error. Both the linked server and the main table (the vs alias) are dynamically added to the query in my full version. I've printed out the SQL statement just before execution and using it statically (i.e. not dynamically) it works fine.
August 24, 2007 at 3:46 pm
Thanks, Andras. Using temporary table seems to work OK.![]()
Viewing 5 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply