From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Challenge: Create a DDL trigger

Challenge: Create a DDL trigger

Now that you've seen how to access event information using the EVENTDATA function, I'd like you to apply that to a new challenge. Use the ChallengeTwo-Start script file to set up the challenge. Your task is to create a trigger that will fire for all table-level DDL events in the KinetEcoTRG database. The trigger will write information from the EVENTDATA function to an EventCapture table about these elements: EventType, UserName, ObjectName, and TSQL command. Finally, run the queries provided in the script to test your solution and see if the expected rows were correctly saved into your EventCapture table. I estimate that this challenge should take about 10 minutes or less to complete. In the next movie, I'll walk through my solution. Good luck.

Contents