exam questions

Exam 70-465 All Questions

View all questions & answers for the 70-465 exam

Exam 70-465 topic 1 question 32 discussion

Actual exam question from Microsoft's 70-465
Question #: 32
Topic #: 1
[All 70-465 Questions]

DRAG DROP -
You are planning to deploy a database to Windows Azure SQL Database.
You need to design a stored procedure to update rows. The stored procedure must meet the following requirements:
✑ If the update fails, an error must be raised to the application and the update must be discarded.
✑ The stored procedure must be designed to maximize concurrency.
What should you include in your design?
To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Note:
* Read Committed is SQL Server's default isolation level.
* @@ROWCOUNT
eturns the number of rows affected by the last statement.
* Using TRYCATCH in a transaction
The following example shows how a TRYCATCH block works inside a transaction. The statement inside the TRY block generates a constraint violation error.
BEGIN TRANSACTION;

BEGIN TRY -
-- Generate a constraint violation error.

DELETE FROM Production.Product -
WHERE ProductID = 980;

END TRY -

BEGIN CATCH -

SELECT -

ERROR_NUMBER() AS ErrorNumber -
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;

IF @@TRANCOUNT > 0 -
ROLLBACK TRANSACTION;
END CATCH;

IF @@TRANCOUNT > 0 -
COMMIT TRANSACTION;

GO -
Reference:
http://msdn.microsoft.com/en-us/library/ms175976.aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
MSSucks
5 years, 5 months ago
In the question the information is missing that the stored procedure should fail if the number of updated records is one or more.
upvoted 1 times
frakcha
4 years, 11 months ago
why would someone create an update SP so that it fails if it updates records ? i don't get it
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...