String or Binary Data Would be Truncated. The Statement has been Terminated
Here I will happy to explain how to solve the issue of “string or binary data would be truncated. The statement has been terminated.” in SQL server.
On one day I am trying to insert data into table using SQL querie at that time
I got error like “String or binary data would be truncated. The statement has been terminated.” Actually this issue because of I declared column datatype varchar(50) but I am inserting data more than 50 characters in that column. To solve this problem I modified column datatype varchar(50) to varchar(100)
Here I will explain with one example I have query like this for insert new record in database
DECLARE @personalDetails TABLE(Id INT, UserName VARCHAR(20),Designation VARCHAR(10))
INSERT INTO @personalDetails (Id,UserName,Designation)
VALUES(1,'vibhav bhavsar','Software Engineer')
SELECT * FROM @personalDetails
If you mark above query I have declared Designation field with VARCHAR(10)
and inserting more than 10 characters into user table so that I got error like
To solve this issue changed Designation datatype size VARCHAR(10) to VARCHAR(50) and run the below query
DECLARE @personalDetails TABLE(Id INT, UserName VARCHAR(20),Designation VARCHAR(50))
INSERT INTO @personalDetails (Id,UserName,Designation)
VALUES(1,'vibhav bhavsar','Software Engineer')
SELECT * FROM @personalDetails
- Thank You
Here I will happy to explain how to solve the issue of “string or binary data would be truncated. The statement has been terminated.” in SQL server.
On one day I am trying to insert data into table using SQL querie at that time
I got error like “String or binary data would be truncated. The statement has been terminated.” Actually this issue because of I declared column datatype varchar(50) but I am inserting data more than 50 characters in that column. To solve this problem I modified column datatype varchar(50) to varchar(100)
Here I will explain with one example I have query like this for insert new record in database
DECLARE @personalDetails TABLE(Id INT, UserName VARCHAR(20),Designation VARCHAR(10))
INSERT INTO @personalDetails (Id,UserName,Designation)
VALUES(1,'vibhav bhavsar','Software Engineer')
SELECT * FROM @personalDetails
If you mark above query I have declared Designation field with VARCHAR(10)
and inserting more than 10 characters into user table so that I got error like
To solve this issue changed Designation datatype size VARCHAR(10) to VARCHAR(50) and run the below query
DECLARE @personalDetails TABLE(Id INT, UserName VARCHAR(20),Designation VARCHAR(50))
INSERT INTO @personalDetails (Id,UserName,Designation)
VALUES(1,'vibhav bhavsar','Software Engineer')
SELECT * FROM @personalDetails
No comments:
Post a Comment