Difficulty: Easy
Correct Answer: Incorrect
Explanation:
Introduction / Context:
SQL Server supports several FOR XML modes (RAW, AUTO, EXPLICIT, PATH) that shape how query results are serialized to XML. This item asserts that EXPLICIT places values as attributes. Understanding each mode’s purpose clarifies why the statement is inaccurate.
Given Data / Assumptions:
Concept / Approach:
EXPLICIT does not inherently force “columns as attributes.” Instead, it lets you design the exact element/attribute mapping by encoding directives in column aliases (for example, Element!Attribute!Directive). RAW and AUTO are the modes commonly associated with default “columns as attributes.” Therefore, the blanket claim about EXPLICIT is incorrect.
Step-by-Step Solution:
Verification / Alternative check:
Compare outputs of FOR XML RAW versus EXPLICIT for the same query. RAW yields attribute-centric rows by default; EXPLICIT requires you to define whether values become attributes or elements.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming all FOR XML modes behave the same; forgetting that EXPLICIT is powerful but complex and largely superseded by PATH for most custom needs.
Final Answer:
Incorrect
Discussion & Comments