I have a SSIS package which is used to export data from a MySQL database to a SQL database. For some reason, I can only read data using the ODBC Source item but I cannot preview the table, also, while doing some other tests I found out I can't insert data with the ODBC Destination item either.
Whenever I try I get this error:
ERROR [42000] [MySQL][ODBC 8.0(w) Driver][mysqld-5.7.23]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "
TABLENAME
" at line 1 (myodbc8w.dll).
I'm using MySQL 5.7.23 and MySQL Connector/ODBC 8.0. I have tried switching between ANSI and Unicode connectors; downgrading the connectors version (tried it with 5.3, 5.2 and 5.1); changing database, table and column codification; changing the data access mode in the ODBC Source item (was using "Table Name" by default); remaking the task. Everything results in the same error, even on different computers and databases.
EDIT:
Using @Hadi second workaround lead to some interesting results (the first one didn't work for me).
Using either the ADO.NET or ODBC connector, the provided query resulted in an error.
Error Code: 1231. Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'
After modifying the query to
set sql_mode = 'STRICT_TRANS_TABLES, NO_ENGINE_SUBSTITUTION, ANSI_QUOTES'
the error changed to a warning.
set sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES' 0 row(s) affected, 1 warning(s): 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
Still, it worked partially. Any quotations, accents, or any other symbol surrounding any selected table name had to be removed. That made it work fine when inserting data, but when retrieving data it had to be done either from a SQL command or by creating 2 different connections.