exam questions

Exam 70-461 All Questions

View all questions & answers for the 70-461 exam

Exam 70-461 topic 1 question 195 discussion

Actual exam question from Microsoft's 70-461
Question #: 195
Topic #: 1
[All 70-461 Questions]

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. DECLARE @Message NVARCHAR(2048); SELECT @Message = FORMATMESSAGE('The record does not exist.'); THROW 51000 , 1 , @Message
  • B. THROW 51000 , 'The record does not exist.' , 1
  • C. THROW ERROR_MESSAGE ('The record does not exist.'), 1
  • D. THROW 51000 , FORMATMESSAGE('The record does not exist.') , 1
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
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

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Dimples205
4 years, 8 months ago
I say its A. According to the book, for THROW; "The message parameter does not allow formatting, but you can use FORMATMESSAGE with a variable to get the same effect."
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...