Question: Stored Procedures (20) 1 4 ) Write a script that creates and calls a stored procedure named spInsertProduct that inserts a row into the Products

Stored Procedures (20)
14) Write a script that creates and calls a stored procedure named spInsertProduct that inserts a row into the Products table. This stored procedure should accept five parameters/arguments. One parameter/argument for each of these columns: CategoryID (int), ProductCode (varchar), ProductName (varchar), ListPrice (smallmoney), and DiscountPercent (smallmoney).
In the procedure, validate the following:
If the value for the ListPrice column is a negative number, the stored procedure should throw an error (using THROW) that indicates that this column doesnt accept negative numbers. If the value for the DiscountPercent column is a negative number, the stored procedure should also throw a similar error (using THROW).
When inserting data into the Products table, set the Description column to an empty string and set the DateAdded column to the current date.
(6) Code at least two EXEC statements that test this procedure (one successful, one failure)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!