exam questions

Exam 70-464 All Questions

View all questions & answers for the 70-464 exam

Exam 70-464 topic 1 question 86 discussion

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

DRAG DROP -
You are a SQL Server 2014 Developer. A database that you work on contains two tables that are defined as follows:

Product is an important table that has sensitive audit requirements.
You need to create a trigger that supports the following requirements:
✑ Every row that is inserted or updated in Product will reflect its actual LastUpdatedDate and LastUpdatedBy values in the Product table.
✑ Any row that is updated or deleted must write a new record reflecting the OLD values into the ProductAudit table.
Any error that occurs during the course of the trigger's execution must prevent the changes from happening.

Develop the solution by selecting and arranging the required code blocks in the correct order.
You may not need all of the code blocks.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Note:
* Executing a ROLLBACK TRANSACTION or COMMIT TRANSACTION Transact-SQL statement inside a stored procedure or trigger is possible, but doing so may cause errors.

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
Luzix
4 years, 7 months ago
To get error i think you should get something like it: BEGIN TRY ... END TRY BEGIN CATCH IF @@ERROR = 0 COMMIT TRANSACTION IF @@ERROR <> 0 ROLLBACK END CATCH
upvoted 1 times
...
Luzix
4 years, 7 months ago
If you put this code like this: COMMIT TRANSACTION IF @@ERROR <> 0 ROLLBACK you will obtain the following error: The transaction ended in the trigger. The batch has been aborted.
upvoted 2 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 ...