From the course: SQL Server Database Triggers
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Solution: Create a DDL trigger - SQL Server Tutorial
From the course: SQL Server Database Triggers
Solution: Create a DDL trigger
(upbeat music) - [Instructor] Let's walk through how I would approach the challenge of writing information about all table level DDL events to a logging table, or what I like to call an event capture table. So the first thing I need to do on this script is just jump into and make sure we're using the KinetEcoTRG database. And then I have a comment here that outlines our objective. So we're going to pull information out of the EventData function, and the information that we're interested in is the EventType, UserName, ObjectName, and TSQL command. So the first thing that I need to do is create a table that'll hold all of this information that comes out of this function. So we can start by writing a CREATE TABLE statement, and I'm going to call this table ChallengeTwoEventCapture. You can call your table whatever you'd like, as long as it doesn't conflict with the table that we already have inside of the KinetEco database over…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.