4
Answers

SQL

Avdhesh Gupta

Avdhesh Gupta

10y
620
1

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)