PdfPrep.com

Which Transact-SQL statement should you run?

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?

A . Option A
B . Option B
C . Option C
D . Option D

Answer: B

Explanation:

The following example shows how to use the THROW statement to raise an exception.

THROW 51000, ‘The record does not exist.’, 1;

Here is the result set.

Msg 51000, Level 16, State 1, Line 1

The record does not exist.

References: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/throw-transact­sql?view=sql-server-2017

Exit mobile version