exam questions

Exam 70-461 All Questions

View all questions & answers for the 70-461 exam

Exam 70-461 topic 1 question 167 discussion

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

SIMULATION -
You need to execute an UPDATE statement that modifies a subset of rows in a table. The rows affected by the UPDATE statement must only be committed if the row count criteria is met.
Part of the correct Transact-SQL has been provided in the answer are below. Enter the code in the answer area that resolves the problem and meets the stated goals or requirements. You can add code within the code that has been provided as well as below it.


Use the "˜Check Syntax' button to verify your work. Any syntax or spelling errors will be reported by line and character position.

Show Suggested Answer Hide Answer
Suggested Answer: Please review the explanation part for this answer.
1. DECLARE @ExprectedRowCount int = 8
2.
3. BEGIN TRAN OrderUpdate
4.
5. UPDATE dbo.OrderHeader
6. SET PromisedDate = DATEADD(dd, 5, PromisedDate)
7. WHERE CustomerID = 8432
8. AND Shipped =0
9.
10. If @@RowCount = @ExpectedRowCount
11.
12. COMMIT OrderUpdate
13.
14. else
15.
16. ROLLBACK OrderUpdate


On line 3 add: BEGIN TRAN -

On line 12 add: COMMIT -

On line 16 add: ROLLBACK -
References:
https://docs.microsoft.com/en-us/sql/t-sql/language-elements/begin-transaction-transact-sql

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
Fadletime
4 years, 4 months ago
If the blank #'s need to be filled with clauses, I think this is a possible solution: 2. WITH 4. AS 9. BEGIN TRAN 11. BEGIN TRY 12. COMMIT OrderUpdate 13. END TRY 15. ROLLBACK 16. TRAN OrderUpdate
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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago