exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 67 discussion

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

DRAG DROP -
You have two tables named UserLogin and Employee respectively.
You need to create a Transact-SQL script that meets the following requirements:
✑ The script must update the value of the IsDeleted column for the UserLogin table to 1 if the value of the Id column for the UserLogin table is equal to 1.
✑ The script must update the value of the IsDeleted column of the Employee table to 1 if the value of the Id column is equal to 1 for the Employee table when an update to the UserLogin table throws an error.
✑ The error message "No tables updated!" must be produced when an update to the Employee table throws an error.
Which five Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-
SQL segments to the answer area and arrange them in the correct order.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:

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
daniel_yes23
Highly Voted 4 years, 11 months ago
CREATE TABLE #UserLogin ( Id int not null, IsDeleted int not null, ); CREATE TABLE #Employee ( Id int not null, IsDeleted int not null, ); insert into #UserLogin values (1, 0) insert into #Employee values (1, 0) BEGIN TRY UPDATE #UserLogin SET IsDeleted = 1 WHERE Id = 0 END TRY BEGIN CATCH BEGIN TRY UPDATE #Employee SET IsDeleted = 'a' WHERE Id = 1 END TRY BEGIN CATCH RAISERROR('No tables updated!', 16, 1) END CATCH END CATCH select * from #UserLogin select * from #Employee
upvoted 8 times
...
daniel_yes23
Highly Voted 5 years ago
Correct answer is the bellow, if you put a catch inside another catch won't throw any error. BEGIN TRY UPDATE #UserLogin SET IsDeleted = 1 WHERE Id = 1 END TRY BEGIN CATCH END CATCH BEGIN TRY UPDATE #Employee SET IsDeleted = 1 WHERE Id = 1 END TRY BEGIN CATCH RAISERROR('No tables updated!', 16, 1) END CATCH
upvoted 5 times
tz_123
4 years, 10 months ago
The above code is incorrect because according to the question, you are only to attempt an INSERT into Employee table *when an update to the UserLogin table throws an error*, whereas the above INSERTs into Employee regardless of whether UserLogin throws an error.
upvoted 6 times
...
...
Andy7622
Most Recent 4 years, 5 months ago
Answer's correct
upvoted 1 times
...
KosteK
4 years, 5 months ago
The same as Q19
upvoted 1 times
...
Aghie
4 years, 8 months ago
in short, the answer is correct
upvoted 2 times
...
Guino
5 years, 2 months ago
- 2 Begin catch - 3 update - 4 begin catch raiserror... - 5 end catch
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