Error string or binary data would be truncated by update in mssql server
I have a table as below :
CREATE TABLE News( Id INT IDENTITY(1,1) NOT NULL, Title NVARCHAR(100) NOT NULL, ShortContent NVARCHAR(1000) NULL )
In this table have to 100k records and I need update Title column value same with ShortContent column and this is my query:
UPDATE News SET Title = ShortContent
But I get an error string or binary data would be truncated. the statement has been terminated. Pls leave a comment if you have any suggestions.
Dung Do Tien Mar 18 2020
If you attention you will find that there are two points of interest.
1. The data type of columns - They are the same
2. Length of columns - They are the difference
Title NVARCHAR(100) NOT NULL, ShortContent NVARCHAR(1000) NULL
In your case, the reason to get this error is points 2, you only need to set length of them are the same. It will be working for you.