Monday, November 18, 2013

String or binary data would be truncated. The statement has been terminated in .net

Introduction:

how to solve the problem of “string or binary data would be truncated. The statement has been terminated". When data Insert in sql server.

 Description:


  In one project I am trying to insert data into one table using SQL queries at that time I got error like “String or binary data would be truncated. The statement has been terminated.” Actually this problem because of I declared column datatype varchar(200) but I am inserting data more than 200+ characters in that column. To solve this problem I modified column datatype varcha (200) to varchar(MAX)

I will explain with one example I have query like this
DECLARE @Details TABLE(UserId INT, Note VARCHAR(MAX))
INSERT INTO @UserDetails(UserId,UserName)
VALUES(1,'Arjun Walmiki','')
SELECT * FROM @Details
If you observe above query I declared Note field with VARCHAR(200) and inserting more than 200 characters because of that I got error like 


 



Note:- Welcome to add your comment and suggestion. 

No comments:

Post a Comment