Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started