Which query should you execute?

You are a database developer on an instance of SQL Server 2008. Your Prod database contains a POMaster table defined as follows:


The Details column contains the line items for each purchase order in the following XML format:
<POLines PONum="12" VendorName="VirtuArt Corporation">
<POLine>
<InvID>001</InvID>
<Quantity>25</Quantity>
<Cost>125.57</Cost>
<Taxable>1</Taxable>
</POLine>
<POLine>
<InvID>002</InvID>
<Quantity>12</Quantity>
<Cost>29.95</Cost>
<Taxable>0</Taxable>
</POLine>
<POLine>
<InvID>003</InvID>
<Quantity>100</Quantity>
<Cost>2.25</Cost>
<Taxable>1</Taxable>
</POLine>
</POLines>
You want to query the POMaster table and return the PurchaseOrderID and OrderDate. You also want the query to return the PONum and VendorName attributes from the XML stored in the Details column for the purchase order.
Which query should you execute?
A. SELECT PurchaseOrderID, OrderDate,
Details.value(‘(@VendorName) [1]’, ‘varchar(30)’) AS Vendor,
Details.value(‘(@PONum)[1]’, ‘int’) AS PONumber
FROM POMaster;
B. SELECT PurchaseOrderID, OrderDate,
Details.value(‘(/POLines/@VendorName) [1]’, ‘varchar(30)’) AS Vendor,
Details.value(‘(/POLines/@PONum)[1]’, ‘int’) AS PONumber
FROM POMaster;
C. SELECT PurchaseOrderID, OrderDate,
Details.value(‘(/POLines/VendorName) [1]’, ‘varchar(30)’) AS Vendor,
Details.value(‘(/POLines/PONum)[1]’, ‘int’) AS PONumber
FROM POMaster;
D. SELECT PurchaseOrderID, OrderDate,
Details.query(‘(/POLines/@VendorName) [1]’, ‘varchar(30)’) AS Vendor,
Details.query(‘(/POLines/@PONum)[1]’, ‘int’) AS PONumber
FROM POMaster;

microsoft-exams

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.