Write for Us
Depending on the event type, the schema then includes additional information such as the database in which the event occurred, the object against which the event occurred, and the Transact-SQL statement of the event.Example:The following example creates a DDL trigger to prevent new tables from being created in the database. The Transact-SQL statement that fires the trigger is captured by using XQuery against the XML data that is generated by Eventdata.USE AdventureWorks;GOCREATE TRIGGER safety ON DATABASE FOR CREATE_TABLE AS PRINT 'CREATE TABLE Issued.'SELECT EVENTDATA().value('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]','nvarchar(max)')RAISERROR ('New tables cannot be created in this database.', 16, 1) ROLLBACK;GO--Test the trigger.CREATE TABLE NewTable (Column1 int);GO--Drop the trigger.DROP TRIGGER safetyON DATABASEGOResult:
Messages:
XML Indexes:For the faster retrieval of XML data, the user can create indexes on these columns.XML indexes fall into the following categories:1) Primary XML index2) Secondary XML indexThe first index on the xml type column must be the primary XML index. Using the primary XML index, the following types of secondary indexes are supported: PATH, VALUE, and PROPERTY. Depending on the type of queries, these secondary indexes might help improve query performance.Primary XML Index:The primary XML index is a shredded and persisted representation of the XML BLOBs in the xml data type column. For each XML binary large object (BLOB) in the column, the index creates several rows of data. The number of rows in the index is approximately equal to the number of nodes in the XML binary large object.
Each row stores the following node information:
Secondary XML Index:To enhance search performance, secondary XML indexes can be created. A primary XML index must first exist before the user creates secondary indexes. These are the types of secondary XML index:
Conclusion:Thus we had a look at how the power of XML can be fully captured in SQL Server 2005.Happy XMLing!!!