Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
SQL
insert into tbl_item_mst
select itemcode,itemname,shortname,companyname,[description],pack,
convert(numeric(18,2),pricetoretailer),convert(numeric(18,2),mrp),convert(numeric(18,2),standardrate),
itemtype,categorycode,divisioncode,brandcode,
pricetostockiest,null,0,'',0,GETDATE(),null,null,0,'',''
from items 

I've been executing above mentioned query I am getting error which i have been mentioned in down.
SQL
Msg 8152, Level 16, State 2, Line 1
String or binary data would be truncated.
The statement has been terminated.
Posted
Updated 18-Mar-15 20:33pm
v4
Comments
Thanks7872 19-Mar-15 1:54am    
You still don't understand the comment i made yesterday. Make proper use of title. Such meaningless titles won't help anyone.
King Fisher 19-Mar-15 2:12am    
I did ;)
Thanks7872 19-Mar-15 2:17am    
OP didn't.

This may occur due to mismatch of data types limit. Check your two tables structure and data types with limits.

You are selecting values from table(Items) and insert into table(tbl_item_mst). For example, if you have column(companyname varchar(10)) in tbl_item_mst and matching column companyname nvarchar(max) from table(Items) it'll not match.
This is an example for a single column,
SQL
tbl_item_mst                        Items
varchar(10)                   !=   nvarchar(max)
CompanyName(varchar(10))      !=   ComapanyName(nvarchar(max))

So, here you can't merge 20 letters with 10 letters, this what the message(Msg 8152) shows. So please check all column data types with its limit.

If my words are not clear to you, refer here about this error,
http://www.sql-server-helper.com/error-messages/msg-8152.aspx[^]
http://www.sqlservercentral.com/Forums/Topic266180-110-1.aspx[^]
 
Share this answer
 
Comments
King Fisher 19-Mar-15 1:39am    
No its not like that. ;)
Rajesh waran 19-Mar-15 1:58am    
Actually I too try to explain what you have said in your solution, that's why i have provide a link to him for further reference.
This error occurs when your try to insert long inputs more than what you declared in that column .

For eg:
SQL
create table testing (Firstname nvarchar(5))--note nvarchar(5)
insert into testing  values('Kings')--Inserted Successfully
insert into testing  values('KingFisher')--Error Occurs


Here,I have created the Column Firstname with nvarchar(5).So the Column will accept only 5 digits of characters only .it will not accept more than 5 digits.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900