Hey guys,I'm trying to insert into a linked server table from sql server (to mysql). I can do this with openquery but it takes forever. I read on the following link that you can make this much faster by doing an Execute ('...') AT MYSQL<linked server> using a table variable.Here is the question and response that gave me the idea: [url]http://www.sqlservercentral.com/Forums/Topic1640834-1550-1.aspx[/url]I'm just struggling with the syntax...and I'm so close I think. Here is what I have so far:[quote]declare @tbl_test TABLE( ID int NOT NULL, pub smallint NULL);insert into @tbl_testSELECT ID ,pub FROM dbo.tbl_live declare @test varchar(max) = 'Insert into tbl_mysql select * from ' + @tbl_test EXECUTE(@test) AT MYSQL[/quote]This gives me the error: Must declare the scalar variable @tbl_test. I also tried putting the variable inside the single quotes...obviously it doesn't get recognized as a variable and when trying to pass to mysql...it has no idea what that is.Anyone have the idea of the sytnax to get this working?
↧