Solved

nvarchar(max)

Posted on 2008-10-24
6
1,168 Views
Last Modified: 2012-05-05
i have a column that i changed to nvarchar(255) to nvarchar(max)

now when I update the data something small like '123'
I get error

no row was updated
the data in row 1 was not committed
Error source: .Net  SqlClient data Provider
Error Message: String or binary data would be truncated
The statement has been terminated

123--is only 3 characters.  I changed it to nvarchar(max), why am i getting this error?
0
Comment
Question by:yanci1179
  • 3
6 Comments
 
LVL 8

Expert Comment

by:jorgesv13
ID: 22799898
Are you using a DataSet / Table Adapter for making the Insert?
Check the field definition of the Datatable in your table adapter.
It might have a low value for "Max Length"
0
 

Author Comment

by:yanci1179
ID: 22799917
i am doing an update on the database itself.  with an update statement and directly to the table
0
 

Author Comment

by:yanci1179
ID: 22800062
i did sp_help on the table and the length is -1 for the column that i changed to nvarchar(max)

I changed it to varchar(1000) and it shows the length correctly. I reverted back to nvarchar(max) and it shows - 1 again.
0
 

Accepted Solution

by:
yanci1179 earned 0 total points
ID: 22800236
okay i figured it out...... stupid actually.  the original table has a trigger on it and was updating the column of another table that was smaller.  once i made the other column nvarchar(max) it worked.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 22804788
Great!  Now please close the question.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question