MySQL > SSMS 2012 Linked Server "Requested conversion is not supported." - mysql

This little gem has kept me going for a wee while now and I'm still not much further forward.
Environment
SSMS 2012 SP1 (target) (Server 2012 64 bit)
MySQL (source)
Linked server using ODBC 5.3 64bit Unicode driver
I am trying to port the tables from MySQL onto SSMS.
A majority of the tables work fine....until I hit a column that is cast > 8000 chars.
As I was having an issue I tried to just select the offending Columnm
Running a simple
SELECT RogueCol FROM LinkServer...MyTbl
returns the error
OLE DB provider "MSDASQL" for linked server "LinkServer" returned message "Requested conversion is not supported.".
Msg 7341, Level 16, State 2, Line 1
Cannot get the current row value of column "[MSDASQL].RogueCol" from OLE DB provider "MSDASQL" for linked server "LinkServer".
So I then tried
SELECT * FROM OPENQUERY(LinkServer, 'SELECT RogueCol FROM MyTbl')
This returns the same error
I'm totally confused as I cannot seem to even view the data in SSMS, let alone SELECT it into a table (I have a script that will cast the fields according to some rules based on their original MySQL castings)
As I say, for a majority of other fields its not an issue.
The MySQL casting of the RogueCol is varchar(32767)
The settings enabled on the MSDASQL Provider is:
Nested Queries
Level Zero Only
Allow Inprocess
Supports 'Like'
So far I've tried a raft of things which I've 'discovered' on various forums including:
CASTING, CONVERTING, LEFT, LTRIM(RTRIM()) on the actual call.
Tried also restricting it to a TOP 1 record (LEN = 45, Doesn't have any white space or foreign characters in the string)
Set up the ANSI version of the ODBC driver
Various settings within the ODBC driver (Allow Big Result sets, changing Character sets, Limit Columns to 32 bit, Pad char with space among others)
Can I call upon your collective knowledge and request some further suggestions please as this driving me nuts?
Many thanks

UPDATE
So guys and girls, no responses
I ended up having to talk to the DBA responsible for the MySQL DB and asked him to alter the casting of the RogueCol from varchar(32767) to TEXT
Job jobbed

Related

MySQL Workbench Migration: MSSQL to MySQL - Incorrect String Value

I have a .NET 6 application that is currently backed by MSSQL database, that is maintained by Entity Framework using a Model First approach. I am trying to migrate it to use a MySQL database backend, for a variety of reasons.
I have installed MySQL Locally (Windows) to start exploring and getting it working. I can migrate the schema easily enough (With either MySQL Workbench or using EF) but migrating the data is proving to be a little tricky.
Around half of the tables migrated fine, but the other half, relating to string data, are failing due to errors which look a little like this - the column obviously differs from table to table. The source data is nvarchar in SQL, and the destination is type `varchar'
Statement execution failed: Incorrect string value: '\xF0\x9F\x8E\xB1' for column 'AwayNote'
Does anyone know how I can get the Migration to run successfully?
The research I have read has said to ensure server and table character sets are aligned as per the below.
I have set up my Source as SQL using the ODBC FreeTDS
The data import screen is set up like this - the check box doesn;t seem to affect things especially.
I have MySQL setup with this too, which I have also read is important.
[mysql]
default-character-set = utf8mb4

SSIS - Deployed package SQL Command validation error

I have created a SSIS package in order to transfer datas from ACCESS to SQL SERVER.
Source > SQL Command from "mdb" file joinning two tables
Destination > Flat table in SQL Server
I'm performing the JOIN in the source SQL Command because of the number of records in the ACCESS tables (~500k).
I tried to use SSIS join but it take ages doing the ORDERING before JOIN.
While running package in VS2010, it works great.
But after deploying and executing the package on my SQL Server 2014 the following error occurs.
No column information was returned by the SQL command.
Returned validation status "VS_NEEDSNEWMETADATA"."
I'm pretty sure my SQL command is correct (Working in VS and the preview button in the editor show me records).
I tried to disable ValidateMetadata but the same error still occurs, but at execution this time.
In the SQL Server 2014 I have other packages calling ACCESS data (But without join) and it works properly.
Thanks for your help,
Q.
ValidateMetadata is (generally) a good thing.
This error is being caused by the metadata on your source or destination (it's unclear from your question) being different.
At a guess, at least one of the columns in your SQL2014 database is of a different datatype (or length, or is nullable etc.) - there is a difference either way.

ODBC call failed - Random date overflow errors after moving from 32-bit ODBC 5.1 to 64-bit 5.3

Background:
Legacy code running in MS Access 2003.
Sqls run by CurrentDB in Access.
Currently running on Windows 7 32-bit machine.
Connecting to MySQL Server 5.5 through a ODBC 5.1 Driver.
Problem:
Trying to migrate to Windows server 2012 64 bit.
ODBC 5.3 Unicode Driver (32 bit).
Don't want to use time rewriting everything as there is a lot of code, and it will in a not to distant future be removed.
Issue:
Several sql statements fail when running on the new servers. Worked on old servers.
All the failed sqls have now() in the statement.
Error description says ODBC call failed. While the more detailed description says date overflow - "[MySQL][ODBC 5.3(w) Driver][mysqlid-5.5.28-log]Date overflow".
Happens randomly, and when it happens and Access stops one can usually just choose continue and the sql will then work. It fails less than 1% of the times it runs (of thousands).
The only dates in the sql are in the where clause: "and fieldA > now()", where fieldA is a datetime column. This is a get recordset sql. Another error during an insert is the same, but where an integer was subtracted from now() before compared to a datetime.
I don't understand why it says date overflow when there doesn't seem to be a reason for the time of either datetime or "now" to be removed? And since the datetime field is already in the database and now() will get current date and time there shouldn't be any invalid dates?
Any help in what the problem might be or how to debug/log anything that might help would be highly appreciated.
Turning trace on in the ODBC driver is not an option because it happens so randomly, there is so much traffic therefore this would slow down everything such that nothing happens.
Note that I also did encounter one sql where the date overflow error message was correct. It seems that prior to 5.3 when inserting a datetime into a date field it was automatically truncated, because a sql which had been successfull 3000 times started failing. Therefore this sql has been fixed by extracting the date from the field first. But the other errors must be something different.
New version containing a bugfix has been released by Oracle: 5.3.8
This error was a bug that seems to have been introduced in version 5.1.11.
In advanced options there is now a Date overflow check box which has to be ticked for the code to continue when there is an error.
Reply from Oracle about the fix:
"For your information the fix approach was that in C or C++ it is possible to read or write DATE type using SQL_TIMESTAMP_STRUCT.
This struct can hold both date and time.
The error (Date overflow) was generated when with operations that are supposed to be DATE-only this struct got non-zero values for time.
That is the canonical approach as ODBC API requires, however, it causes inconveniences sometimes when for instance the app did not bother
to initialize the whole structure with 0 values because it knows it will only need the DATE part but the random values for TIME fraction could cause the errors despite of being truncated.
A new option was introduced to continue with the query execution rather then return error.
The server will ignore the TIME part and the result is the same as if there were zeroes."
This appears to be an issue with MySQL Connector/ODBC versions 5.2 and later. A web search led to this thread on another site, which in turn led to this unresolved bug report. Note that this is a broader MySQL Connector/ODBC issue; it is not specific to Access applications.
MySQL Connector/ODBC 5.1.13 is still available for download, so your most expedient solution would probably be to simply use that version until the code in question is taken out of service. Your other alternatives might include:
using a newer version of MySQL Server (with [better?] support for fractional seconds), or
tweaking the Access SQL queries to use something other than the Now() function (which you, understandably, would like to avoid).
I had exactly the same problem - "Date overflow" error when saving the data in an Access form.
I changed the data type from "datetime" to "timestamp" in the linked MySQL table and this solved the issue. The datetime data type seems to be too short to accommodate the value of Now() in MS Access.
Remember to refresh the linked tables in Access afterwards.
I also noticed that there was a "Not Null" tick mark next to the ModifyTime timestamp field in the MySQL table. I unticked this.
After these two changes I no longer get the Date Overflow error when Me.Dirty=False executes in Access.
I use Access365 (x64), MySQL ODBC Connector 8.0.31 (x64) and MySQL 5.6

MySQL as Linked Server on SQL Server 2008 - Data Length Mismatch

I am trying to set up a third party MySQL as a Linked Server on SQL Server 2008.
When I try to access the data via a simple OpenQuery below I get an error.
SELECT * FROM OpenQuery(SERVERNAME, 'SELECT * FROM table')
The error message:
OLE DB provider 'MSDASQL' for linked server 'SERVERNAME' returned data that does not match expected data length for column '[MSDASQL].tablename'. The (maximum) expected data length is X, while the returned data length is Y.
NOTE:(where X > Y)
I've tried with another MySQL table that I built myself and it works fine. Therefore I assume the problem might be with the MySQL source.
EDIT: After digging a little deeper into the MySQL data I found several "invalid" dates such as zero dates. These could be a reason, however I have no way to change the data source so I must find a way to convince SQL to ignore it.
I recall something form previous versions of SQL where you could switch to "Lazy Schema Validation" to force SQL not to check this. However this option appears to be gone in 2008.
Any ideas how I could make this work?

How do you coerce float values in MySQL for classic ASP scripts?

I have been charged with maintaining a legacy classic ASP application. The application uses an ODBC system DSN to connect to a MySQL database.
We had to recently update the servers to satisfy some licencing requirements. We were on Windows, with MySQL 4.x and the 3.51 ODBC driver. We moved to a Linux machine running MySQL 5.1.43 and are running the 5.1.6 ODBC driver on the new IIS server.
Users almost instantly started reporting errors as such:
Row cannot be located for updating.
Some values may have been changed
since it was last read.
This is a ghost error, and the same data changes, on the same record, at a different time won't always produce the error. It is also intermittent between different records, as in, sometimes, no matter what values I plug in, I haven't been able to repro the defect on all records.
It is happening across 70 of about 120 scripts, many over 1,000 lines long.
The only consistency I can find is that on all of the scripts that fail, they are all reading/writing floats to the DB. Fields that have a null value don't seem to crash, but if there is a value like '19' in the database (note the no decimal places) that seems to fail, whereas, '19.00' does not. Most floats are defined as 11,2.
The scripts are using ADODB and recordsets. Updates are done with the following pattern:
select * from table where ID =
udpdated recordID
update properties of the record from the form
call RecordSet.Update and RecordSet.Close
The error is generated from the RecordSet.Update command.
I have created a workaround, where rather than select/copy/update I generate an SQL statement that I execute. This works flawlessly (obviously, an UPDATE statement with a where clause is more focused and doesn't consider fields not updated), so I have a pretty good feeling that it is a rounding issue with the floats that is causing a mis-match with the re-retrieval of the record on the update call.
I really would prefer NOT re-writing 100's of these instances (a grep across the source directly finds 280+ update calls).
Can anyone confirm that the issue here is related to floats/rounding?
And if so, is there a global fix I can apply?
Thanks in advance,
-jc
Have a look at MySQL Forums :: ODBC :: Row cannot be located for updating.
They seem to have found some workaround and some explanations as well..
I ran into a similar issue with a VBA macro utilizing 4.1. When upgraded to 5 errors started popping up.
For me the issue was that values being returned to VBA from MySQL was in a unhandled (by VBA) decimal format.
A CAST on the numbers when querying helped to fix the issue.
So for your issue perhaps the ODBC/ASP combination is recording/reading values differently then what you might expect them to be.