PdfPrep.com

Which Transact-SQL statement should you run?

You have a table that was created by running the following Transact-SQL statement:

You need to query the Courses table and return the result set as JSON. The output from the query must resemble the following format:

Which Transact-SQL statement should you run?
A . SELECT CourseID AS [Course ID], Course as NameFROM Courses FOR JSON PATH(‘Courses’)
B . SELECT CourseID AS ‘Course ID’, Course AS NameFROM Courses FOR JSON ROOT(‘Courses’)
C . SELECT CourseID AS [Course ID], Course AS NameFROM Courses FOR JSON AUTO, ROOT(‘Courses’)
D . SELECT CourseID AS ‘Course ID’, Course AS NameFROM Courses FOR JSON AUTO, INCLUDE_NULL_VALUES(‘Courses’)

Answer: C

Explanation:

Incorrect Aswers:

D: The input would cause error as INCLUDE_NULL_VALUES doesn’t accepts any input parameters.

References: https://docs.microsoft.com/en-us/sql/relational-databases/json/include-null-values-in-json-include-null­values-option?view=sql-server-2017

Exit mobile version