[Solved]Chapter 14 3 3 Pts Write Script Declares Variable Sets Count Products Products Table Count Q37187951


SQL(Chapter 14) 3. (3 pts) Write a script that declares a variable and sets it to the count of all products in the Products table. If the count is greater than or equal to 7, the script should display a message that says, “The number of products is greater than or equal to 7”. Otherwise, it should say, “The number of products is less than 7” (3 pts) Write a script that calculates the common factors between 10 and 20. To find a common factor, you can use the modulo operator (%) to check whether a number can be evenly divided into both numbers. Then, this script should print lines that display the common factors like this Common factors of 10 and 20 1 2 4. (Chapter 15) 5. (3 pts) Write a script that creates and calls a stored procedure named <your initials>spInsertCategory. First, code a statement that creates a procedure that adds a new row to the Categories table. To do that, this procedure should have one parameter for the category name. Code at least two EXEC statements that test this procedure. (Note that this table doesn’t allow duplicate category names.) 6. (3 pts) Write a script that creates and calls a function named <your initials>fn DiscountPrice that calculates the discount price of an item in the Orderltems table (discount amount subtracted from item price). To do that, this function should accept one parameter for the item ID, and it should return the value of the discount price for that item. (3 pts) Write a script that creates and calls a function named <your initials fnItem Total that calculates the total amount of an item in the Orderltems table (discount price multiplied by quantity) To do that, this function should accept one parameter for the item ID, it should use the DiscountPrice function that you created in exercise 6, and it should return the value of the total for that item 8. (3 pts) Create a copy of the Products table by entering the following statement: into <your initials>Products From Products Select Create a trigger named <your initials>Products INSERT that inserts the current date for the Date Added column of the Syour initials>Products table if the value for that column is null. Test this trigger with an appropriate INSERT statement. Show transcribed image text (Chapter 14) 3. (3 pts) Write a script that declares a variable and sets it to the count of all products in the Products table. If the count is greater than or equal to 7, the script should display a message that says, “The number of products is greater than or equal to 7”. Otherwise, it should say, “The number of products is less than 7” (3 pts) Write a script that calculates the common factors between 10 and 20. To find a common factor, you can use the modulo operator (%) to check whether a number can be evenly divided into both numbers. Then, this script should print lines that display the common factors like this Common factors of 10 and 20 1 2 4. (Chapter 15) 5. (3 pts) Write a script that creates and calls a stored procedure named spInsertCategory. First, code a statement that creates a procedure that adds a new row to the Categories table. To do that, this procedure should have one parameter for the category name. Code at least two EXEC statements that test this procedure. (Note that this table doesn’t allow duplicate category names.) 6. (3 pts) Write a script that creates and calls a function named fn DiscountPrice that calculates the discount price of an item in the Orderltems table (discount amount subtracted from item price). To do that, this function should accept one parameter for the item ID, and it should return the value of the discount price for that item. (3 pts) Write a script that creates and calls a function named Products table if the value for that column is null. Test this trigger with an appropriate INSERT statement.
Expert Answer
Answer to (Chapter 14) 3. (3 pts) Write a script that declares a variable and sets it to the count of all products in the Products… . . .
OR

