Avdhesh Gupta

Avdhesh Gupta

  • NA
  • 7
  • 3.1k

SQL

Jul 26 2014 7:05 AM

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

Answers (4)