Which query should you use?
You have the following XML document that contains Product information.
DECLARE @prodList xml =’
<ProductList xmlns="urn:Wide_World_Importers/schemas/Products">
<Product Name="Product1" Category="Food" Price="12.3" />
<Product Name="Product2" Category="Drink" Price="1.2" />
<Product Name="Product3" Category="Food" Price="5.1" />
…
</ProductList>’;
You need to return a list of products that contains the Product Name, Category, and Price of each product.
Which query should you use?
Which code segment should you use?
You have a table named Stores that has an XML column named OpenHours.
This column contains the opening and closing times.
<hours dayofWeek= "Monday" open ="8:00 AM" closed="8:00 PM"
<hours dayofWeek= "Tuesday" open ="8:00 AM" closed="8:00 PM"
…
<hours dayofWeek= "Saturday" open ="8:00 AM" closed="8:00 PM"
You need to write a query that returns a list of stores and their opening time for a specified day.
Which code segment should you use?
What result should you expect?
You work for a company that provides marketing data to other companies.
You have the following Transact-SQL statement:
DECLARE @CustomerDemographics XML SET @CustomerDemographics=N’
<CustomerDemographics>
<Customer CustomerID="1" Age="21" Education="High School">
<IsCoffeeDrinker>0</IsCoffeeDrinker>
</Customer>
<Customer CustomerID="2" Age="27" Education="College">
<IsCoffeeDrinker>1</IsCoffeeDrinker>
<IsFriendly>1</IsFriendly>
</Customer>
<Customer CustomerID="3" Age="35" Education="Unknown">
<IsCoffeeDrinker>1</IsCoffeeDrinker>
<IsFriendly>1</IsFriendly>
</Customer>
</CustomerDemographics>’
DECLARE @OutputAgeOfCoffeeDrinkers XML
SET @OutputAgeOfCoffeeDrinkers = @CustomerDemographics.query(‘
for $output in /child::CustomerDemographics/child::Customer[( child::IsCoffeeDrinker[1] cast as xs:boolean )]
return <CoffeeDrinkingCustomer> { $output/attribute::Age } </CoffeeDrinkingCustomer>’)
SELECT @OutputAgeOfCoffeeDrinkers
You need to determine the result of the query. What result should you expect?
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?
Which Transact-SQL statement should you use?
Your company’s database contains Customers and Orders tables.
You have been tasked to write a SELECT statement that exposes the data as a valid and well-formed
XML document. The XML data must be attribute-based, and the order data XML must be nested in the customer data XML.
You need to write a SELECT statement to meet the requirements.
Which Transact-SQL statement should you use?
Which FOR XML statement should you use?
Your company’s database contains Customers and Orders tables.
You have been tasked to write a SELECT statement that outputs customer and order data as a valid and well-formed XML document. You are required to mix attribute and element based XML within the document. You have determined that using the FOR XML AUTO clause will not be suitable.
You need to identify the correct FOR XML clause to meet the requirement.
Which FOR XML statement should you use? (Each correct answer represents a complete solution. Choose two.)
Which query should you use?
You need to generate the following XML document.
<ProductExport>
<Product Price="99">Product1</Product>
<Product Price="199">Product2</Product>
<Product Price="299">Product3</Product>
<Product Price="399">Product4</Product>
</ProductExport>
Which query should you use?
Which query should you use?
You have two tables named Customers and Orders. They are related by a foreign key constraint on the CustomerID on each table. You need to generate the following XML structure that includes all customers and their related orders.
<Root>
<Customer>
<CustomerName>Customer1</CustomerName>
<Orders>
<Order>
<OrderDate>1/1/2008</OrderDate>
<OrderValue>422</OrderValue>
</Order>
<Order>
<OrderDate>4/8/2008</OrderDate>
<OrderValue>300</OrderValue>
</Order>
…
</Orders>
…
</Customer>
<Root>
Which query should you use?
Which function should you use?
You have implemented change tracking on a table named Sales.SalesOrder.
You need to determine all columns that have changed since the minimum valid version.
Which function should you use?
Which Transact-SQL statement should you use?
You are required to modify a table named Sales.SalesOrder. The table has change tracking enabled on it.
You need to disable change tracking prior to modifying the Sales.SalesOrder table.
Which Transact-SQL statement should you use?