Which code segment should you use?
You have an XML schema that you must use to validate XML data in your database. You need to store this XML schema. Which code segment should you use?
Which catalog view should you use?
Your company exchanges information with other companies by using XML and Web services. Your manager asks you to remove a schema collection that is no longer used. Before dropping the schema, you should confirm that it is no longer in use.
You need to use a catalog view to determine if the schema collection is being used. Which catalog view should you use?
Which query should you write?
You have a table named Products.Product. The table has columns ProductID, Name, Size, and Category.
You have a variable named @XML with following XML value:
<Root>
<Category Name="Socks" />
<Category Name="Pants" />
<Category Name="Shirts" />
</Root>
You are tasked to write a query that lists the products in Products.Product that match the categories listed in the XML document. You need to write a query to accomplish the task. Which query should you write?
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?