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 2000 Forums
 SQL Server Development (2000)
 How to insert data from a table into a table

Author  Topic 

JNotenboom
Starting Member

27 Posts

Posted - 2001-02-20 : 10:23:11
Hello,

I have a problem with one of my statments. I want to insert records from one table into another table. These two tables have the same primary keys set up. In fact, I want to insert the records which do not exist in the destination table. Code:

insert tbl_X
select Sales, CustCode, YTDUnits, YTDAmount, SalesPreviousYear
from tbl_Y
minus
select Sales, CustCode, YTDUnits, YTDAmount, SalesPreviousYear
from tbl_X

The code generates this error:
Server: Msg 213, Level 16, State 4, Line 1
Insert Error: Column name or number of supplied values does not match table definition.

what is going wrong and can it be the MINUS word? Is there an alternative?

thanx

Johan Notenboom
Intelli Solutions


   

- Advertisement -