Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Insert into statement giving error terminating

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2014-12-28 : 08:42:12
I am trying to use the below insert, receiving below error.Not sure what is causing the error. select query runs absolutely fine with no issues, but with insert giving error.

Msg 8152, Level 16, State 13, Line 24
String or binary data would be truncated.
The statement has been terminated.


insert into tab_contracts ([ProgID]
,[ProjID]
,[ContractNO]
,[ContractCode]
,[ContractName]
,[ContractDescription],deleted)
SELECT 71, 1220,[NIT], [NIT],
ltrim(rtrim(replace([Razón Social],'"',''))), 'Business Type Contracts',0
FROM [Contadores_Juridicos_Business_NIT]
where [Razón Social] is not null
group by [Razón Social],[NIT]





Thanks a lot for the helpful info.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-12-28 : 10:16:48
the error is cause by one of the values because one of the columns in the FROM table is longer than one of the columns in the INSERT INTO table.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2014-12-28 : 12:53:56
Thank you very much, That was the issue. It worked now.

Go to Top of Page
   

- Advertisement -