Advertisement

01.18.2006 at 09:05AM PST, ID: 21701208
[x]
Attachment Details

Error Msg while performing UPDATE on Linked Server: String or binary data would be truncated.

Asked by nathan8 in MS SQL Server

Tags: binary, data, openquery, string, would

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,

-NateStart Free Trial
[+][-]01.18.2006 at 10:01AM PST, ID: 15731328

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.18.2006 at 11:07AM PST, ID: 15731954

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2006 at 08:49AM PST, ID: 16225193

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]03.22.2006 at 01:29AM PST, ID: 16255701

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: binary, data, openquery, string, would
Sign Up Now!
Solution Provided By: CetusMOD
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32