From the course: SQL Server Database Triggers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Reading the EVENTDATA() XML - SQL Server Tutorial
From the course: SQL Server Database Triggers
Reading the EVENTDATA() XML
- [Instructor] DDL triggers aren't fired by data modification events. So it may seem obvious that they don't use the same inserted and deleted tables like their DML counterparts. But what DDL triggers do have access to is the full list of events and parameters that were sent to the server that caused the trigger to fire. When writing a trigger, you can access this information using a SQL server function called EVENTDATA. The EVENTDATA function returns data as XML text. So, you'll have to dig into the EVENTDATA XML schema in order to make use of it. You can find the full schema description at this URL. Now this is an extremely long document, so you'll want to use your browser's Find in Page function to quickly jump to the section that you want to review. So let's run through an example. I want to find all the information that's available about any Create_Table events that execute on my database. Do a search through the XML…
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.