title: Using EXEC() AT [Linked Server] for Insert data from local server
body: <p>let me first explain a little abot my setup before letting you know the issue Im dealing with:</p>
  
  <p>I have two database servers: SQL 2008 and MySql. I have a procedure in SQL that first, deletes a table in MySql and then populates it with some data from the SQL itself. For both actions im using OPENQUERY. But, as you know, it doesnt know support large data. It becomes really slow eventhou for truncating the table in MySql (it was taking like 14 minutes to delete 60k rows... insane!).</p>
  
  <p>So i found out i could use this syntax for truncating:</p>
  
  <p><strong><em>EXEC ('TRUNCATE TABLE table_name') AT LINKEDSERVER</em></strong></p>
  
  <p>But i havent been able to find the syntax for inserting the results of the SQL table to my MySql table thru this. It works correct when I insert static data, like this example:</p>
  
  <p><strong><em>EXEC ('INSERT INTO table_name (row1, row2) VALUES (value1, value2)') AT LINKEDSERVER</em></strong></p>
  
  <p>But I want to insert the results from a SQL, as I said, something like this:</p>
  
  <p><strong><em>EXEC ('INSERT INTO table_name (row1, row2) SELECT r1, r2 FROM SQL_DB.sql_table_name') AT LINKEDSERVER</em></strong></p>
  
  <p>I bet that i cannot do it because in that syntax, Im executing the exec in the MySql server and the SQL table doesnt exist there. So how can i referrence my SQL table inside the "EXEC() AT" syntax?</p>
  
  <p>Thank you.</p>