Tuesday, February 2, 2010

What are XML indexes and secondary XML indexes?

Answer
The primary XML index is a B+tree and is useful because the optimizer creates a plan for the entire query.
It is always better to split the entire XML columns into relational rows and columns.
The primary XML index contains one row for each node in the XML instance.
The secondary XML indexes can be created to enhance the performance.
There are the types of secondary indexes:
PATH secondary XML index
If the use of path expressions on XML columns is prominant, the PATH secondary XML index can speed up the task.
VALUE secondary XML index
The VALUE index can be used if your task involves quering unknown attribute names.
PROPERTY secondary XML index
Clustering paths within each XML instance in the PROPERTY index can be beneficial when multiple values are retrieved from individual XML instances. 

What is the purpose of FOR XML in SQL Server?

Answer
SQL Server 2000 provides the facility to retrieve data in the form of XML with the help of the FOR XML clause appended to the end of a SELECT statement.
There are 3 types of FOR XML modes — RAW, AUTO, and EXPLICIT.
They all generate a different style of XML document

What is the OPENXML statement in SQL Server?

Going through thousands of lines of XML degrades performance to a great extent.This is where the OPENXML function comes into use. It does the parsing work for you quite efficiently.
The syntax of OPENXML is:
OPENXML(idoc int [in],rowpattern nvarchar[in],[flags byte[in]]) [WITH (SchemaDeclaration | TableName)]
OPENXML function is supposed to be used with two system stored procedures:
1.sp_xml_preparedocument
2.sp_xml_removedocuments  

0 Comments: