From the course: SQL Server Database Triggers

Unlock the full course today

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

Writing data from the EVENTDATA() function

Writing data from the EVENTDATA() function - SQL Server Tutorial

From the course: SQL Server Database Triggers

Writing data from the EVENTDATA() function

- [Instructor] Let's take a look at what the event data function returns by writing the contents to a table. In the last movie we reviewed all of the elements returned when SQL server executes a create table statement. First I'm going to create a table that has a column for each of these elements. The table that I'll create is called TableEventCapture. And here you can see the different columns that I'm about to create. We have one that corresponds to each row being returned from the XML table. So here's EventType, PostTime, SPDID and so on. Each of these all store as mvarchar 100 datatype except for the TSQL command which needs to be a little bit longer. So I'll save that out as mvarchar 2000. Let's highlight lines one through 17 and execute them to create that table. And now we can turn our attention to creating the trigger. That'll fill in rows of data into that table. So I'll create a trigger called TableCreateEvent.…

Contents