PrepAway - Latest Free Exam Questions & Answers

You need to retrieve all levels by using a single Transact-SQL query

You are a database developer. You plan to design a database solution by using SQL Server
2008. The database will contain a table that has a parent-child relationship to itself. Each
child might also be a parent. This might exist up to 10 levels deep. You need to retrieve all
levels by using a single Transact-SQL query. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Write a query to return the first level, and then use the CROSS JOIN operator to join the
table back to itself to get the remaining levels.

B.
Create a common-table expression to return the first level and then union back to itself to
get the remaining levels.

C.
Write a query to return the first level, and then add a correlated subquery to get the
remaining levels.

D.
Create a view that returns the first level, and then use the FULL OUTER JOIN operator
to join the table back to the view to get the remaining levels.

Explanation:


Leave a Reply