How to do insert one row from one table to another table(what has less columns)?

Posted by chobo2 on Stack Overflow See other posts from Stack Overflow or by chobo2
Published on 2010-05-31T23:38:31Z Indexed on 2010/05/31 23:43 UTC
Read the original article Hit count: 180

Filed under:
|
|

Hi

I am trying to find rows that are not in one table and insert them into another. The table I am trying to insert into has less columns then the other one.

These columns are null but it would be cool if I could hardcode a value before I do the insert.

But I am having so much trouble with just trying to get it to insert.

I have something like this

SELECT p.ProductId, p.ProductName
INTO SomeTable
FROM Product as p
WHERE p.ProductName != 'iPad'

I will get a error like this though

Msg 4104, Level 16, State 1, Line 1 The multi-part identifier "p.ProductId" could not be bound.

I am not sure what I am doing wrong. I copied and pasted the names in so I don't think it is a spelling mistake.

I am using ms sql 2005 express.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server