Developing SQL Databases — Question 168
Note: this question is part of a series of questions that use the same or similar answer choices. An answer choice may be correct for more than one question in the series. Each question is independent of the other questions in the series. Information and details provided in a question apply only to that question.
You are developing an application to track customer sales.
You need to create a database object that meets the following requirements:
- Return a value of 0 if data inserted successfully into the Customers table.
- Return a value of 1 if data is not inserted successfully into the Customers table.
- Support TRY"¦CATCH error handling
- Be written by using Transact-SQL statements.
What should you create?
Answer options
- A. extended procedure
- B. CLR procedure
- C. user-defined procedure
- D. DML trigger
- E. scalar-valued function
- F. table-valued function
Correct answer: D
Explanation
The correct answer is D, a DML trigger, because it can automatically execute upon data modification events, such as insertions. The other options, such as extended procedures, CLR procedures, and functions, do not inherently support automatic execution on data changes and do not fulfill the specified requirements for error handling and return values.