Question: Question 2 (5 points) Create a stored procedure that accepts a parameter ProductID and has an OUTPUT parameter that returns the number sold for the
Question 2 (5 points)
Create a stored procedure that accepts a parameter ProductID and has an OUTPUT parameter that returns the number sold for the product.
Make use of the Sales.SalesOrderDetail table to accomplish this.
2a) What is the SQL code to create this stored procedure ?
2b) Provide an example code to execute your stored procedure.
Question 3 (5 points)
Just because someone leaves the company, a product is discontinued, or other situations we almost never wish to delete the data completely from a database. On the Product table create a trigger such that when someone deletes a product from the product table, the product is not actually deleted. Instead, we wish to set the discontinued date to the current date.
3a) What is the SQL code to define this trigger?
3b) Provide example SQL code that will cause your trigger to fire.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
