hello everyone, after spending most of the day trying to figure this out i hope that you guys with more experience can provide some suggestions. i have been experimenting with the a linked server (MYSQL 5) and managed to get all the select queries to work fine, but the insert is giving me troubles. MSSQL is 2008 R2, the odbc connector is the most recent.
so here is some useful testing material:
-- Table structure for myTest on the MYSQL server-- ----------------------------DROPTABLEIFEXISTS `myTest`;CREATETABLE `myTest` ( `id` bigint(20) NOTNULL, `mystring` varchar(50) COLLATE utf8_unicode_ci DEFAULTNULL, `mydate` datetimeDEFAULTNULL,PRIMARYKEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;-- ------------------------------ Records -- ----------------------------INSERTINTO `myTest` VALUES ('1', 'string1', '2009-04-17 13:11:41');INSERTINTO `myTest` VALUES ('2', 'strin2', '2009-04-17 13:12:48');INSERTINTO `myTest` VALUES ('3', 'string3', '2009-12-09 12:29:48');INSERTINTO `myTest` VALUES ('4', 'nostring', '2009-12-18 12:29:48');INSERTINTO `myTest` VALUES ('5', 'stfing5', '2010-07-17 16:40:00');
then i copied the data from mysql to MSSQL and made up new data and copied it into the 'local' copy of the mysql table:
-- copy stuff from mysqlselect * into [msTest]fromopenquery(MYSQL, 'select * from myTest');--make a copy and change a row for this exampleselect * into [msTestCopy]from [msTest];UPDATE [msTestCopy]SET [id] = 10 ,[mystring] = 'sadfasdfas' ,[mydate] = '2009-04-17 14:11:41.0000000'where [ID] =1;-- insert new row in the imported tabledeclare @myId asint;set @myId=10;insertinto [msTest] ([ID],[mystring],[mydate])select T1.[ID], T1.[mystring], T1.[mydate]from [msTestCopy] T1where T1.[ID] = @myId;
Then i tried an update query which was successful:
UPDATEOPENQUERY (MYSQL, 'SELECT mystring FROM mydatabase.myTest WHERE id = 1') SET mystring = 'sadfasdfas';
Now this is where things just do not work. i tried an insert with the following:
-- insert in mysqlinsertOPENQUERY(MYSQL, 'SELECT * FROM myTest')select * FROM [dbo].[msTest] T1where T1.[ID] = @myId;
the error returned is not very useful"
Msg 7399, Level 16, State 1, Line 5
The OLE DB provider "MSDASQL" for linked server "MYSQL" reported an error. The provider did not give any information about the error.
Msg 7343, Level 16, State 2, Line 5
The OLE DB provider "MSDASQL" for linked server "MYSQL" could not INSERT INTO table "[MSDASQL]". Unknown provider error.
then i went back to basics and tried the following
insertOPENQUERY(MYSQL, 'SELECT * FROM myTest')values (7,'sadfasdfas','2009-04-17 14:11:41.0000000')
similar error as a result:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "MYSQL" reported an error. The provider did not give any information about the error.
Msg 7343, Level 16, State 2, Line 1
The OLE DB provider "MSDASQL" for linked server "MYSQL" could not INSERT INTO table "[MSDASQL]". Unknown provider error.
Does anyone have any clue of what is happening and how i could solve it?