Querying Microsoft SQL Server 2012/2014 — Question 18

You develop a database application for Microsoft SQL Server and Microsoft Azure SQL Database.
You need to raise an exception and transfer execution to a CATCH block.
You need to ensure that the exception returns output in the following format:
Msg 51000, Level 16, State 1, Line 1
The record does not exist.
Which Transact-SQL statement should you run?

Answer options

Correct answer: B

Explanation

The correct answer is B because it directly raises an exception with the specified message format and includes the appropriate error number. Options A, C, and D either do not format the message correctly or use functions that do not align with the required output structure.