Question: Exercise 16-2 [20 points] Write a script that includes these statements coded as a transaction: INSERT Orders VALUES (3, GETDATE(), '10.00', '0.00', NULL, 4, 'American
Exercise 16-2 [20 points] Write a script that includes these statements coded as a transaction:
INSERT Orders VALUES (3, GETDATE(), '10.00', '0.00', NULL, 4, 'American Express', '378282246310005', '04/2019', 4);
SET @OrderID = @@IDENTITY;
INSERT OrderItems VALUES (@OrderID, 6, '415.00', '161.85', 1);
INSERT OrderItems VALUES (@OrderID, 1, '699.00', '209.70', 1);
Here, the @@IDENTITY variable is used to get the order ID value thats automatically generated when the first INSERT statement inserts an order.
If these statements execute successfully, commit the changes. Otherwise, roll back the changes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
