I'm trying to execute a EXEC connecting a Linked Server, but it does not working using a table variable.
Is there any fix for that?
My code:
DECLARE @Table TABLE(
ID VARCHAR(8),
DATA DATE,
DIA VARCHAR(2),
MES VARCHAR(2),
ANO VARCHAR(4)
)
INSERT INTO @Table SELECT * FROM LOCALTABLE
EXEC ('INSERT INTO SERVER2TABLE SELECT * FROM ' + @Table) AT SERVER2;
The error:
Must declare the scalar variable "@Table".
My Servers:
SQL SERVER 2008 R2 LINKED SERVER using MySQL ODBC 5.1 Driver MySQL 5.6.8