1 Write Script Includes Statements Coded Transaction Insert Orders Values 3 Getdate 1000 0 Q37048340

1. Write a script that includes these statements coded as atransaction:

INSERT Orders VALUES (3, GETDATE(), ‘10.00’, ‘0.00’,NULL, 4, ‘American Express’, ‘378282246310005’, ’04/2013′,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 orderID value that’s automatically generated when the first INSERTstatement inserts an order. If these statements executesuccessfully, commit the changes. Otherwise, roll back thechanges.

here is my code am using sql management studio and am getting aerror using “EXCEPTION”

INSERT Orders VALUES (3, GETDATE(), ‘10.00’, ‘0.00’,NULL, 4, ‘American Express’, ‘378282246310005’, ’04/2013′,4);

SET @OrderID = @@IDENTITY;

INSERT OrderItems VALUES (@OrderID, 6,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.