My setup:
SQL Server 2000
MySQL ODBC Driver 3.51.12
MySQL 4.0.18
I have created a Linked Server in MS SQL to connect to an MySQL database. I can perform SELECTs and UPDATEs without any problems, except in one situation...
In my MySQL table, Contacts, I have a field named City. This field is a VARCHAR(64). I want to UPDATE all of my Contacts where City='Akron' and SET City='Cleveland'. I try to do this in the following manner:
SET XACT_ABORT ON
GO
UPDATE OPENQUERY(MYSQLSERVER, 'SELECT City FROM Contacts WHERE City="Akron"') SET City='Cleveland'
GO
I receive the following error:
Server: Msg 8152, Level 16, State 9, Line 1
String or binary data would be truncated.
Now, I can update my table with any string shorter or equal in length to "Akron". For instance, I can run the following query, and see exactly the change I want to see:
SET XACT_ABORT ON
GO
UPDATE OPENQUERY(MYSQLSERVER, 'SELECT City FROM Contacts WHERE City="Akron"') SET City='Lodi'
GO
I'm assuming that the problem is that my City column is a VARCHAR. How can I get around this without changing the column type? Or, is changing the column type the only option? If so, should I change it to CHAR?
Thanks,
-Nate
Start Free Trial