Tuesday, April 2, 2013

String or binary data would be truncated. MSSQL ERROR

String or binary data would be truncated.








Error Message:
Msg 8152, Level 16, State 14, Line 5
String or binary data would be truncated.

Severity level:
16.

Description:
This error message appears when you try to insert a string with more characters than the column can maximal accommodate.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Errors of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. You must either shorten the string to be isnerted to widen the column.

Versions:
All versions of SQL Server.

Example(s):
USE tempdb;
IF OBJECT_ID(‘tempdb.#t’) > 0
DROP TABLE #t
GO
CREATE TABLE #t
(
c1 CHAR
);
INSERT INTO #t SELECT ‘abc’
GO


Remarks:
In the above example we try to insert a string ‘abc’ with a length of 3 into the column c1 of the table #t. Because c1 is of the data type CHAR(1), the error is raised.



hope this post helped! you might be more intrested in,
important links : MSSQL, SQL Server, ERROR


let me know if you have any issue ! write me for freelancing projects ! 

Reactions:

0 comments:

Post a Comment

Any Questions or Suggestions ?

About

Professional & Experienced Freelance Developer From India, Technologist, Software Engineer, internet marketer and Open Sources Developer with experience in Finance, Telecoms and the Media. Contact Me for freelancing projects.

Enter your email address:

Delivered by FeedBurner

PHP Freelancer India - Google+