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
 General SQL Server Forums
 New to SQL Server Programming
 Simple insert into statement

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-12-02 : 05:57:02
I am trying to insert a line of data into a table from a temp table.

code as follows

insert into nominess_list ([Status], Total)
(select 'New Nominees £s', count(contact_ref) from Nominess
having count(contact_ref) >0)

and result is as follows

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

this has got to be something small.

MCTS / MCITP certified

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2010-12-02 : 06:03:31
check the size of the columns in which you are inserting data.the size of the either columns is small then that of the data you are passing to it.
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-02 : 06:04:00
What size is Status?
'New Nominees £s' is 15 characters

I take it Total is a numeric datatype.

no need for the brackets

insert into nominess_list ([Status], Total)
select 'New Nominees £s', count(contact_ref)
from Nominess
having count(contact_ref) >0)


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-12-02 : 06:09:34
O MY GOD

how careless is that, thank you for answering such a stupid mistake.
Go to Top of Page
   

- Advertisement -