Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert into error

Status
Not open for further replies.

lagazetta

Technical User
May 3, 2007
8
CA
hi there,


when i use the below script to insert 2 columns of a table(named actual flow) into an already existing table (named merged2):

insert into merged2
select ustie, abtie
from actual_flow

i get the following error message:

Msg 213, Level 16, State 1, Line 2
Insert Error: Column name or number of supplied values does not match table definition.

i created 2 columns in merged2 table, named ustie and abtie and the number of values equal to each other in those two tables.

can you see where I am making a mistake?

thanks,


 
Yes, if you have more columns in the table than you are inserting you need to referrence them

insert into merged2 (ustie, abtie)
select ustie, abtie
from actual_flow

- Paul
10qkyfp.gif

- If at first you don't succeed, find out if the loser gets anything.
 
i tried:

insert into merged2 (ustie,abtie)
select ustie, abtie
from actual_flow

i got:

Msg 515, Level 16, State 2, Line 2
Cannot insert the value NULL into column 'KEY', table 'CABREE.dbo.merged2'; column does not allow nulls. INSERT fails.
The statement has been terminated.

it tries to put my values into my first column, but I want to put those values into my last two columns, named ustie and abtie.
the column KEY is my first column's name, and it tries to put the values in that column.
i don't get why..
 
it tries to put my values into my first column, but I want to put those values into my last two columns, named ustie and abtie.
the column KEY is my first column's name, and it tries to put the values in that column.
i don't get why..
Actually it isn't trying to put your records in the KEY column. It is telling you the column KEY must have a value.

Do you have any other not null columns in the table? They will need to be in your INSERT statement and you must have values for them.


- Paul
10qkyfp.gif

- If at first you don't succeed, find out if the loser gets anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top