HELP with an INSERT INTO statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone,

I received the response below for a previous question. I understand the
logic behind the reply, and I am sure it will work. I can't, however, figure
out what I should be substituting for '2345' in the "SELECT '2345' AS" part
of the solution below?

I'm getting very close to running out of time and would greatly appreciate
any assistance.

Regards,

Franc.

Hi Franc,
 
Hi!

If I understand what you are trying to do (selecting data from SalesOrders
and inserting the selected data to CreditNotes), then I think you should:

INSERT INTO CreditNoteLines (
CreditNoteID, SalesOrderID, PartNumber, Description, Quantity, UnitPrice, Tax)
SELECT CreditNoteID,SalesOrderID, PartNumber, Description,Quantity,
UnitPrice, Tax
FROM SalesOrderLines
WHERE SalesOrderID = '9876';

Hope this helps!

- Beginner -
 
'Beginner' is probably right. The way you have it, with the '2345', will
cause the first field to always have a value of '2345'. I'm assuming you
really want that field to have the value of the CreditNoteID field, whcih is
what you'll get with that Beginner showed you. I think you only want to use
the 'AS' clause if you want a constant as a value (like you had with the
'2345'), or if you are calculating a value (e.g. Field1/Field2), or if you
want to rename a field.
 
Back
Top