Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

You want to make sure that rows in the Sales.Orders table (TSQL2012 database) are archived when deleted. You have created the table Sales.OrdersArchive that has the same columns / data types as Sales.Orders, plus one additional column, Archived, of type datetime, to store the date and time the row is written to the archive table. Archived has a default value of CURRENT_TIMESTAMP.
Because of the foreign key constraint in the Sales.OrderDetails table on the orderid column, you know you cannot delete a row from Orders without first deleting all rows with the same orderid value from OrderDetails. You create a table Sales.OrderDetailsArchive that has the same columns / data types as Sales.OrderDetails, plus the Archived column of type datetime with default value CURRENT_TIMESTAMP. 
To solve the deletion problem, 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
If you want to create the two Archive tables to test your trigger, see the scripts in the "Unit5.Create Archive Tables.sql" file in Doc Sharing. (25)
b. In the pubs database, create a stored procedure that will INSERT an employee. You can develop the procedure in the same way as the procedure in Exercise 2 starting on page 486 is developed. Your finished procedure should have all relevant parameter testing. Only the finished CREATE PROC code should be given in your Assignment document. Also show a call to the procedure that would insert an employee.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M979718

Have any Question?


Related Questions in Computer Engineering

Why would a policy of re-importation of prescription drugs

Why would a policy of re-importation of prescription drugs be ineffective?

Aa stock will pay dividends of 3 4 and 9 over the next

aA stock will pay dividends of $3, $4, and $9 over the next three years, and then increase dividends at a rate of 3% afterwards. Its required rate of return is 15%. What is the value of the stock? Round to the penny.

Are there manufacturers and retailers who have taken steps

Are there manufacturers and retailers who have taken steps to reduce their pollution impact, both air quality and industrial pollution, while maintaining a viable place in the market?

Imagine a small city chambana with a labor demand function

Imagine a small city Chambana with a labor demand function E=200-1/2w and a labor supply function E=2w-100. Assume that there is a sudden influx of 40 perfect substitutes immigrants. a. How does this affect the natives i ...

Cwrite function that takes an array of doubles and the

C++ Write function that takes an array of doubles and the array length as parameters (compute the array length using size of, don't just put in the number 5). In the function, find and return the largest value. Write sec ...

The contracts manager at a company needs to make a large

The contracts manager at a company needs to make a large legal document available to an overseas customer. However, she has some challenges: The document contains sensitive information; it is too large to send via e-mail ...

From slide number 1-37 how did we get value 00004 show all

From slide number 1-37, how did we get value 0.0004? Show all your work. Describe the most popular wireless Internet access technologies today. Compare and contrast them. What is the key distinguishing difference between ...

Switches are an integral part of networks they are the

Switches are an integral part of networks. They are the devices you utilize for host connectivity to the network. Please identify and discuss an attack that takes advantage of a weakness in switches.

Suppose that we have a binary counter with k bits where

Suppose that we have a binary counter with k bits, where each bit is stored in a array A[0..k - 1]. The operation Increment(A) increments the counter by adding 1 to the content of the counter modulo 2k . The cost of this ...

Configuring name resolutionas the administrator of the

Configuring Name Resolution As the administrator of the Contoso Corporation, you manage an internal website that is often used by most users with the company. You try to connect to an internal website but cannot open the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As