PrepAway - Latest Free Exam Questions & Answers

Which query should you use?

You have a table named Customer that has an XML column named Locations. This column stores an
XML fragment that contains details of one or more locations, as show in the following examples.

<Location City="Sydney" Address="…" PhoneNumber="…" />
<Location City="Chicago" Address="…" PhoneNumber="…" />
<Location City="London" Address="…" PhoneNumber="…" />

You need to write a query that returns a row for each of the customer’s locations. Each resulting row must
include the customer name, city, and an XML fragment that contains the location details.
Which query should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
SELECT CustomerName, Locations.query(‘for $i in /Location return data($i/@City)’), Locations.query(‘for $i in /Location return $i’)
FROM Customer

B.
SELECT CustomerName, Locations.query(‘for $i in /Location return element Location {$i/@City, $i}’)
FROM Customer

C.
SELECT CustomerName, Locations.query(‘data(/Location/@City)’), Locations.query(‘/Location’) FROM Customer

D.
SELECT CustomerName, Loc.value(‘@City’,’varchar(100)’), Loc.query(‘.’)
FROM Customer CROSS APPLY Customer.Locations.nodes (‘/Location’) Locs(Loc)


Leave a Reply