Which action should you take?

You are a database developer on an instance of SQL Server 2008. Your Prod database contains the following tables:


You have a stored procedure, AddPurchaseOrder, which accepts a table-valued input parameter containing the purchase order details, begins a transaction, and inserts the appropriate rows into the PurchaseOrder and POLines tables.
The AddPurchaseOrder stored procedure then calls the UpdInventory stored procedure to update inventory quantities for the products sold on the purchase order. The UpdInventory stored procedure is defined as follows:
CREATE PROCEDURE UpdInventory(@InvID int, @qty int)AS
BEGIN TRANSACTION
UPDATE Inventory SET UnitsInStock = UnitsInStock - @qty WHERE InvID = @InvID;
INSERT INTO InvQtyHistory(InvID, Adj, Description)VALUES (@InvID, @qty, ‘Inventory adjustment for purchase order’);
COMMIT TRANSACTION
The Inventory table contains a CHECK constraint on the UnitsInStock column that prevents it from being updated to a negative value. You want to ensure that if the UpdInventory stored procedure attempts to update the UnitsInStock table with a negative value, then no inserts or updates to any of the tables will be committed.
Which action should you take?
A. Set the XACT_ABORT option to OFF at the beginning of the AddPurchaseOrder stored procedure.
B. Set the XACT_ABORT option to ON at the beginning of the AddPurchaseOrder stored procedure.
C. Set the XACT_ABORT option to ON at the beginning of the UpdInventory stored procedure.
D. Include the code for both stored procedures in a single stored procedure that includes a TRY…CATCH block.

microsoft-exams

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.