Database Fundamentals — Question 107

You work as a database developer for www.company.com.com.
The company has a database named www.company.com that is hosted on a SQL Server 2008 server. The database includes a table named Employees, which contains the details of the employees.
You want to ensure that anytime any data in the Employees table is modified with an UPDATE statement, they are recorded in a table named EmployeeChanges.
The EmployeeChanges table includes columns to record what the change was, who made the change, and when they made the change.
What should you create to meet this need?

Answer options

Correct answer: B

Explanation

The correct answer is B, as a DML trigger is specifically designed to handle data manipulation events like INSERT, UPDATE, and DELETE. In this case, querying the inserted table in a DML trigger allows you to log the changes made to the Employees table accurately. Options A and C are incorrect because DDL triggers are used for changes to the structure of the database rather than data changes, and option D does not appropriately capture the details needed for the logging purpose.