exam questions

Exam 70-461 All Questions

View all questions & answers for the 70-461 exam

Exam 70-461 topic 1 question 202 discussion

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

SIMULATION -
The following is a series of questions in which you are required to input one or more lines of code.

To input your response -
Type your response into the text entry field in the Answer Area. You may input one or more lines of code. More than one solution may be correct. You will receive credit if your solution matches any of the correct solutions.

To validate code syntax -
After entering your code, click the Check Syntax button. This validates code syntax (such as SQL commands) and values (such as table names and variable names) used in your solution. If there are any errors, they will appear in the window next to the Check Syntax button. You may change your code and re-validate the syntax as many times as you want.
Note that Check Syntax does NOT validate whether you have answered the question correctly. It simply validates the accuracy of your syntax.
To view available command keywords
Click the Keywords button to view a list of command keywords. This is a general list provided for reference and is not limited to commands used in the question.
You plan to deploy a stored procedure for a database named TICKETS.
You need to implement error handling for the stored procedure to ensure that the system-defined error messages are returned if an error occurs upon insert.
Part of the correct Transact-SQL has been provided in the answer are below. Enter the code in the answer area that resolves the problem and meets the stated goals or requirements. You can add code within the code that has been provided as well as below it.


Show Suggested Answer Hide Answer
Suggested Answer: Please review the explanation part for this answer.
1 CREATE PROCEDURE AdCase
2 @CustomerId INT,
3 @ProblemId INT,
4 @Comment NVARCHAR (MAX)
5 AS
7 BEGIN TRY
8 INSERT INTO Cases
9 (CustomerId, ProblemId, Comment)
10 VALUES
11 (@CustomerId, @ProblemId, @Comment)
12 END TRY
13 BEGIN CATCH
14 INSERT INTO AppLog
15 (CurrentTime, ErrorNumber, CustomerId)
16 VALUES
17 (getdate(), ERROR_NUMBER(), @CustomerId);
18 THROW;
20 END CATCH

Make changes and additions in the above lines.
7 BEGIN TRY
12 END TRY
13 BEGIN CATCH
18 THROW;
20 END CATCH
References:
https://docs.microsoft.com/en-us/sql/t-sql/language-elements/try-catch-transact-sql?view=sql-server-2017 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
lilupv
4 years, 9 months ago
In exam this answer returns "spelling error" when checking correctness of the written code. I don't know why.
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 ...