Link to home
Start Free TrialLog in
Avatar of directxBOB
directxBOBFlag for Ireland

asked on

Copying a Row?

I have an Orders Table and I would like to copy an Order and assign it to another Order.

The only thing that would be required to changed would be the field CustomerID where I would change the customerID for that order.

The obvious approach would be to copy out all the fields from the order and insert it into the new row. But is there anyway automate this so it automatically does the insert and update for me?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of directxBOB

ASKER

Can you explain how this works?

Mainly :

SELECT 2, getdate()
  FROM order_table
 WHERE CustomerID = 1
   AND OrderID = 123456
actually, the example was not really "speaking"..
you will need to insert into and query more of the "order_Table" columns, but as I don't know your table/column names...

Yes I understood that part but I wasn't really sure about:

SELECT 2, getdate()

2 would be the new customerid, and getdate() as "new" order date for the new rows..