Here are all the actual test exam dumps for IT exams. Most people prepare for the actual exams with our test dumps to pass their exams. So it's critical to choose and actual test pdf to succeed.
Actual exam question for Microsoft's DP-800 exam Question #: 13 Topic #: 2
You have an Azure SQL database that contains a table named dbo.Orders. You have an application that calls a stored procedure named dbo.usp_tresteOrder to insert rows into dbo. Orders. When an insert fails, the application receives inconsistent error details. You need to implement error handling to ensure that any failures inside the procedure abort the transaction and return a consistent error to the caller. How should you complete the stored procedure? To answer, drag the appropriate values to the correct targets, tach value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point.
Suggested Answer:
Explanation: * After the INSERT # SET @OrderId = SCOPE_IDENTITY() * Inside CATCH # IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION The correct drag-and-drop choices are: * SET @OrderId = SCOPE_IDENTITY() * IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION After the INSERT, the procedure should assign the newly generated identity value to the output parameter by using SCOPE_IDENTITY() . Microsoft documents that SCOPE_IDENTITY() returns the last identity value inserted in the same scope, which makes it the correct choice for returning the new OrderId from the procedure. Inside the CATCH block, the procedure should use IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION before THROW. This ensures any open transaction is rolled back only when one actually exists, which prevents transaction-state issues and guarantees the failure aborts the transaction cleanly. Keeping THROW after the rollback is also the correct modern pattern because THROW re-raises the error to the caller with the original error information intact, giving consistent error behavior. This matches SQL Server best practice for TRY...CATCH transaction handling.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Is the comment made by USERNAME spam or abusive?
Commenting
In order to participate in the comments you need to be logged-in.
You can sign-up / login
(it's free).
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).