nerdexam
Microsoft

70-433 · Question #18

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…

The correct answer is C. DECLARE @Day VARCHAR(10) = 'Tuesday'. CREATE TABLE Stores( StoreName VARCHAR(10)NOT NULL, OpenHours [xml] NULL, CONSTRAINT [PK_Stores] PRIMARY KEY CLUSTERED (StoreName)) INSERT INTO Stores (StoreName, OpenHours) '<hours dayofWeek= "Wednesday" open ="8:00 AM" closed="8:00 PM"/> <hours dayofWeek= "Tuesday" open…

Implement Tables and Views

Question

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?

Options

  • ADECLARE @Day VARCHAR(10) = 'Tuesday'
  • BDECLARE @Day VARCHAR(10) = 'Tuesday'
  • CDECLARE @Day VARCHAR(10) = 'Tuesday'
  • DDECLARE @Day VARCHAR(10) = 'Tuesday'

How the community answered

(33 responses)
  • A
    6% (2)
  • C
    85% (28)
  • D
    9% (3)

Explanation

CREATE TABLE Stores( StoreName VARCHAR(10)NOT NULL, OpenHours [xml] NULL, CONSTRAINT [PK_Stores] PRIMARY KEY CLUSTERED (StoreName)) INSERT INTO Stores (StoreName, OpenHours) '<hours dayofWeek= "Wednesday" open ="8:00 AM" closed="8:00 PM"/> <hours dayofWeek= "Tuesday" open ="9:00 AM" closed="8:00 PM"/> <hours dayofWeek= "Friday" open ="8:00 AM" closed="8:00 PM"/>'), '<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"/>') DECLARE @Day VARCHAR(10) = 'Tuesday' SELECT Storename, OpenHours.query('data(/hours[@dayofWeek=sql:variable("@Day")]/ @open)')

Topics

#XQuery#XML column#value() method#SQL XML

Community Discussion

No community discussion yet for this question.

Full 70-433 Practice