Fra kurset: SQL Server Database Triggers

Få tilgang til hele kurset i dag

Bli med i dag og få tilgang til over 23,400 kurs som undervises av bransjeeksperter.

Solution: Create a DDL trigger

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…

Innhold