Question
I need these 3 queries completed, thank you. /* Query 1 . (10 points) Write an INSERT statement with an OUTPUT clause to add a
I need these 3 queries completed, thank you.
/* Query 1. (10 points)
Write an INSERT statement with an OUTPUT clause to add a new row to the Categories table in MyGuitarShop database. The OUTPUT clause must display the new inserted values of both columns of Categories. The CategoryName of this new row is 'Brass'. Your INSERT statement should not insert a value into the CategoryID column because this column is an IDENTITY column, meaning its values are generated automatically by the server.
Hint: see lecture video about how to add an OUTPUT clause to meet theabove requirement.
*/
/* Query 2. (10 points)
Once Query 1 is done, write an UPDATE statement with an OUTPUT clause to modify rows of Categories table. This statement should change the CategoryName valueby appending "***" to its end if the CategoryName value begins with a letter 'B'. The OUTPUT clause must display three columns: CategoryID column, 'Old_CategoryName' column for the CategoryName value before update, and 'New_CategoryName' column for the CategoryName value after update.
/* Query 3. (30 points)
Once Query 2 is done, write a DELETE statement to delete rows of Categories table if their CategoryName value ends with '***'.
When you execute this statement, it will produce an error since these categories to be deleted have related rows in the Products table. You may open or create a database diagram to easily see how these tables are related. To fix that, precede the DELETE statement with another DELETE statement that deletes all products in these categories.
Hint: use a subquery in the WHERE clause of the DELETE statement.
Again, when you execute this new statement to delete products that are related to the above categories, you get another error since these products have related rows
in OrderItems table. Using the same approach, precede the above DELETE statement with another new DELETE statement that deletes all order items related to the products that
belong to categories whose CategoryName value ends with '***'.
Hint: this DELETE statement requires a subquery nested in another subquery.
Include an OUTPUT clause in all three DELETE statements, each must display all columns of the rows that are deleted.
Correct answer of this query should contain three DELETE statements in the following order. The first one contains two levels of subqueries to delete rows from OrderItems
table. The second one contains only one level of subquery to delete rows from Products table. And, the third DELETE statement deletes rows of Categories table with no subquery.
***Table Description***
dboCategories Columns O CategorylD (PK, int, not null) E CategoryName (varchar(255), not null) dboProducts Columns ProductlD (PK, int, not null) o CategorylD (FK, int, null) ProductCode (varchar(10), not null) ProductName (varchar(255), not null) Description (text, not null) ListPrice (money, not null) Discountpercent (money, not null) DateAdded (datetime, null) EE dbo.OrderItems Columns o ItemID (PK, int, not nul) OrderlD (FK, int, null) ProductID (FK, int, null) ltemPrice (money, not null) DiscountAmount (money, not null) Quantity (int, not null) E dbo.Orders Columns OrderlD (PK, int, not null) oCustomerlD (FK, int, null) OrderDate (datetime, not null) ShipAmount (money, not null) TaxAmount (money, not null) | | ShipDate (datetime, null) ShipAddressID (int, not null) CardType (varchar(50), not null) CardNumber (char(16), not null) CardExpires (char(7. not null) BillingAddressID (int, not null)
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