Title: SQL Server-XML-Lesson 5-Using OpenRowSet() and EVENTDATA()
Duration: 20 minutes
Summary: In this video, we continue the discussion on using xml within SQL Server. The main subjects here are OpenRowSet and EVENTDATA(). There are three primary methods of connecting to remote data source: OpenRowSet, OpenDataSource, and Linked Server. Linked server is usually set up when you are reading data from the remote source constantly. But if you are doing one time deal of reading data, then it is better to use OpenRowSet or OpenDateSource. In this case, we used OpenRowSet to read the content of Books.xml file and insert the data in a Books table. We also talked about using EVENTDATA to retrieve specific DDL (Data Definition Language) information. We created a trigger for DDL_DATABASE_LEVEL_EVENTS. When the user issues a DDL command (create a table), the information is retrieved from EVENTDATA and stored in an xml variable. We can use this information for audit purposes (as we did here). We stored the event type and the sql command issued by the user in MyAudit table.
Methodology of the development of example: Good coding standard and simplified design to illustrate the key points.
Technology Used: SQL Server 2008.
Keywords: XML, table, database, primary key, OpenRowSet, Bulk, SINGLE_BLOB, query(), EVENTDATA, trigger, value(), EVENT_INSTANCE, EventType, suser_sname(), GetDate().