70-451 · Question #131
You are a database developer. You plan to create a database by using SQL Server 2008. The database has a table named Employees. The table contains records of employees and their managers. The table…
The correct answer is B. Create a scalar-valued function by using the FOR XML PATH clause and the TYPE directive. See the full explanation below for the reasoning.
Question
You are a database developer. You plan to create a database by using SQL Server 2008. The database has a table named Employees. The table contains records of employees and their managers. The table includes the EmployeelD and ManagerlD fields. The EmployeelD values are unique. The value in the ManagerlD field is the employee ID of the employee's manager. A Web site requires XML formatted output of all managers and employees to be displayed as a tree diagram. You need to produce the required output by querying the database without using system stored procedures. What should you do?
Options
- ACreate a table-valued function by using the hierarchyid data type.
- BCreate a scalar-valued function by using the FOR XML PATH clause and the TYPE directive.
- CCreate a scalar-valued function by using the OPENXML () function.
- DCreate a table-valued function by using a common table expression (CTE).
How the community answered
(51 responses)- A14% (7)
- B76% (39)
- C4% (2)
- D6% (3)
Community Discussion
No community discussion yet for this question.