Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is too long. Maximum length is 128. Error

Status
Not open for further replies.

maneland

Programmer
Mar 24, 2006
24
ES
I try to Update a field of a table using this statement

UPDATE Table SET field="Forget.......(long text)" WHERE id=1

and I get this error

The identifier that starts with 'Forget your bus excursions. Marta Patiño takes a trip out of this world at La Laguna's Science Museum. In April 2001, De' is too long. Maximum length is 128.

What is wrong?
 
I suspect your problem is that the field you are trying to store that data in to isn't long enough for the data you are trying to insert.

Try making the field bigger.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Do you have any triggers on this table?

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Your problem may be caused by apostrophe's. I noticed that you are using quotes around your string. So, I suggest you change your code like so...

Update Table
Set Field='data'
Where Id = 1

A problem occurs when you are trying to save data with an apostrophe in it. SQL Server thinks that the data is done, and then it expects to find more code (not data). To accomodate apostrophe's in the data, you need to double it. Like so...

Update Table
Set Field = 'Here[!]''[/!]s an apostrophe.'
Where Id = 1

Notice that there are 2 apostrophes where you would normally expect to see 1. When executing this query, the entire string will get stored in the field, but there will ONLY be 1 apostrophe in the word (Here's).


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
thanks and If I want to use double quote, what should I change in the Update code?

Update Table
Set Field = 'the name is ""Peter"".'
Where Id = 1

that´s right?
 
You don't need to do anything special for the quote. Here's an example that you can copy/paste to QA to test.

Code:
Create Table #Temp(Data VarChar(1000))

Insert Into #Temp Values('Here''s an apostrophe.')
Insert Into #Temp Values('Here''s a quote(")')

Select * From #Temp

Drop Table #Temp

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top