What is the result?

Your Prod database resides on an instance of SQL Server 2008. The Item table contains details for each item sold by your company. The Item table has an ItemNo column that is defined as the table’s primary key.
You execute the following Transact-SQL:
CREATE PROCEDURE DeleteItem(@ItemNo int)AS
SAVE TRANSACTION ProcSave1;
BEGIN TRANSACTION;
BEGIN TRY
DELETE FROM Item WHERE ItemNo = @ItemNo;
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS ErrorMessage;
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;
END CATCH;
IF @@TRANCOUNT > 0 COMMIT TRANSACTION;
What is the result?
A. If the item passed as input to the procedure exists, it will be successfully deleted.
B. If the item passed as input does not exist, an error message will be displayed.
C. The code generates an error because you cannot use a ROLLBACK TRANSACTION statement within a CATCH block.
D. The code generates an error because you cannot create a savepoint outside a transaction.

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.