create an INSTEAD OF trigger, Sales.tr_ArchiveOrders, that watches the Sales.Orders table for a DELETE and instead does the following:
1. Copies all relevant rows from Sales.Orders to Sales.OrdersArchive
2. Copies all relevant rows from Sales.OrderDetails to Sales.OrderDetailsArchive
3. Deletes those rows from Sales.OrderDetails
4. Finally, deletes the relevant rows from Sales.Orders
| orderid |
| custid |
| empid |
| orderdate |
| requireddate |
| shippeddate |
| shipperid |
| freight |
| shipname |
| shipaddress |
| shipcity |
| shipregion |
| shippostalcode |
| shipcountry |

Guest UserRank #259 · 9.8K reputationPosted Jul 26, 2014, 6:43 AM EDT
if you want to select data from one table and insert into other, so look for cursors implementation
if you need more details i can provide.
Avdhesh Gupta7 reputationPosted Jul 26, 2014, 6:53 AM EDT
if you can
Guest UserRank #259 · 9.8K reputationPosted Jul 26, 2014, 7:01 AM EDT
create an INSTEAD OF trigger, Sales.tr_ArchiveOrders, that watches the Sales.Orders table for a DELETE and instead does the following:
Avdhesh Gupta7 reputationPosted Jul 26, 2014, 7:23 AM EDT