Which code segment should you use?

A table named Shirts includes an XML column named SizeAndColors that contains the sizes and colors of each shirt, as shown in the following code segment.
<shirt size="XS" colors="Red"/><shirt size="S" colors="Red, Blue" />…<shirt size="XL" colors="Blue, Green" />
You need to return a list of shirt colors available in a specific size.
Which code segment should you use?
A. DECLARE @Size VARCHAR(10) = ‘L’
SELECT ShirtStyleName,SizeAndColors.value(‘/shirt[1]/@colors’,’color’)
FROM Shirts
WHERE SizeAndColors.exist(‘/shirt[@size=sql:variable("@Size")]’) = 1
B. DECLARE @Size VARCHAR(10) = ‘L’
SELECT ShirtStyleName,SizeAndColors.query(‘data(/shirt[@size=sql:variable("@Size")]/@colors)’)
FROM Shirts
C. DECLARE @Size VARCHAR(10) = ‘L’
SELECT ShirtStyleName,SizeAndColors.value(‘/shirt[1][@size =sql:variable("@Size")]/@ colors, ‘color’)
FROM Shirts
D. DECLARE @Size VARCHAR(10) = ‘L’
SELECT ShirtStyleName,SizeAndColors.value(‘/shirt[1]/@colors’,’color’)
FROM Shirts
WHERE SizeAndColors.value(‘/shirt[1]/@size’,’varchar(20)’) = @Size

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.