Question: 1. Write a SELECT statement that returns an XML document that contains all of the invoices in the Invoices table that have more than one
1. Write a SELECT statement that returns an XML document that contains all of the invoices in the Invoices table that have more than one line item. This document should include one element for each of these columns: InvoiceNumber, InvoiceDate, InvoiceTotal, InvoiceLineItemDescription, and InvoiceLineItemAmount. Then, save the XML document thats returned in a file named MultipleLineItems.xml.
You may use this FOR XML clause to convert and save the query results in an XML file -----
FOR XML AUTO, ROOT ('MultipleLineItems'), ELEMENTS;
A sample XML file MultipleLineItems.xml is posted with this assignment.
2. Write a script that uses the XML document shown below to update the contact information in the Vendors table.
To accomplish this, begin by storing this XML document in a variable of the XML type. Then, you can use two UPDATE statements to update the Vendors table.
3. Write a script that returns a result set that contains all of the data stored in the XML document in exercise 2.
You may use OPENXML statement, execute the stored procedures sp_Xml_PrepareDocument and sp_Xml_RemoveDocument
Here is the result set ----
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
