What should you do?

You are creating an online catalog application that will display product information on the company Web site. The product data is stored in a SQL Server 2005 database. The data is stored as relational data but must be passed to the application as an XML document by using FOR XML. You test your application and notice that not all of the items matching your query appear in the XML document. Only those products that have values for all elements in the schema appear.
You need to modify your Transact-SQL statement so that all products matching your query appear in the XML document. What should you do?

You are creating an online catalog application that will display product information on the company Web site. The product data is stored in a SQL Server 2005 database. The data is stored as relational data but must be passed to the application as an XML document by using FOR XML. You test your application and notice that not all of the items matching your query appear in the XML document. Only those products that have values for all elements in the schema appear.
You need to modify your Transact-SQL statement so that all products matching your query appear in the XML document. What should you do?

A.
Add an XML index to the table that contains the product data.

B.
Add the XSINIL argument to the ELEMENTS directive in the query.

C.
Add a HAVING clause to the query.

D.
Add the replace value of clause to the query.

Explanation:
If you add the XSINIL instruction to the ELEMENTS clause in the FOR XML construction, SQL Server 2005 generates an empty XML element for NULL values.



Leave a Reply 0

Your email address will not be published. Required fields are marked *