exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 163 discussion

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

DRAG DROP -
You run the following Transact-SQL statement:

You need to create a stored procedure that meets the following requirements:
✑ Inserts data into the Employees table.
✑ Processes all data changes as a single unit of work.
✑ Sets the exception severity level to 16 and an error number of 60, 000 when any error occurs.
✑ If a Transact-SQL statement raises a runtime error, terminates and reverts the entire unit of work, and indicates the line number in the statement where the error occurred.
✑ Inserts the value New Employee for the Title column if no title is provided.
How should you complete the Transact-SQL statement? To answer, drag the appropriate Transact-SQL segment to the correct target. Each Transact-SQL segment 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.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
References:
https://stackoverflow.com/questions/180075/executing-a-stored-procedure-inside-begin-end-transaction

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
Bartek
Highly Voted 5 years, 9 months ago
Xact_state () tile and Throw (if there II be ";" before it statement) II work this same as @@trancount and raiserror
upvoted 5 times
Tr4ckz
5 years, 8 months ago
Not with Xact_state <> 0 (compare 3 valued xact logic to @@trancount logic which UNLIKE xact state should be 0 to indicate all transactions are closed)
upvoted 2 times
...
mattia_88
5 years, 8 months ago
no ,because there isn't XACT_ABORT ON
upvoted 12 times
...
...
koo
Highly Voted 5 years, 2 months ago
shouldn't it be THROW? in order to return the line number of error
upvoted 5 times
Anette
5 years ago
it gives error when adding THROW instead of RAISERROR. Meanwhile, even RAISERROR gives the line number error
upvoted 1 times
...
...
Billybob0604
Most Recent 4 years, 5 months ago
It should be RAISERROR just because rollback tran does not end with a ; Thing with this is that when applying this error number you actually would need to register it in the sys.message. Error message of used error message is as follows : but no message with that error number was found in sys.messages
upvoted 1 times
...
Vermonster
4 years, 5 months ago
@@TRANCOUNT and THROW
upvoted 1 times
Vermonster
4 years, 5 months ago
A bit more research and XACT_STATE may be better but both should work... Hard to test because I can't get a difference
upvoted 1 times
Vermonster
4 years, 5 months ago
Biggest thing is THROW over RAISERROR because it reports the line number where the error occurred vs. where RAISERROR was called. Tested this.
upvoted 1 times
...
...
...
HA2020
4 years, 7 months ago
it needs to be THROW because one of the requirement states: 'terminates and reverts the entire unit of work'. raiserror does not do that, throw does.
upvoted 1 times
HA2020
4 years, 7 months ago
While raiserror only aborts if severity >20
upvoted 1 times
HA2020
4 years, 7 months ago
just noticed it is rolling back after if statement...
upvoted 1 times
...
...
...
getstoopid
4 years, 10 months ago
Without the ';' at the end of the rollback statement the use of throw would raise a syntax error. so raiserror is indeed correct.
upvoted 2 times
...
Anette
5 years ago
I think its OK. Tested
upvoted 2 times
...
vermeilyn
5 years, 1 month ago
I can't think of why THROW cannot be used here.
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 ...