Home » Microsoft » 70-466 v.2 » What should you use?
You are creating a table named Orders. You need to ensure that every time a new row is added to the Orders table, a user-defined function is called to validate the row before the row is added to the table.
What should you use? More than one answer choice may achieve the goal. Select the BEST answer.
A. A FOREIGN KEY constraint
B. A data manipulation language (DML) trigger
C. A DEFAULT constraint
D. A CHECK constraint
E. A Data Definition Language (DDL) trigger
Correct Answer: B
Explanation/Reference:
Explanation:
DML triggers is a special type of stored procedure that automatically takes effect when a data manipulation language (DML) event takes place that affects the table or view defined in the trigger. DML events include INSERT, UPDATE, or DELETE statements. DML triggers can be used to enforce business rules and data integrity, query other tables, and include complex Transact-SQL statements.
Incorrect Answers:
D: CHECK constraints enforce domain integrity by limiting the values that are accepted by one or more columns. You can create a CHECK constraint with any logical (Boolean) expression that returns TRUE or FALSE based on the logical operators.
References: https://docs.microsoft.com/en-us/sql/relational-databases/triggers/dml-triggers