Microsoft 70-761 Exam Practice Questions (P. 4)
- Full Access (201 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #16
HOTSPOT -
You need to develop a Transact-SQL statement that meets the following requirements:
✑ The statement must return a custom error when there are problems updating a table.
✑ The error number must be value50555.
✑ Theerror severity level must be14.
✑ A Microsoft SQL Server alert must be triggered when the error condition occurs.
Which Transact-SQL segment should you use for each requirement? To answer, select the appropriate Transact-SQL segments in the answer area.
Hot Area:

You need to develop a Transact-SQL statement that meets the following requirements:
✑ The statement must return a custom error when there are problems updating a table.
✑ The error number must be value50555.
✑ Theerror severity level must be14.
✑ A Microsoft SQL Server alert must be triggered when the error condition occurs.
Which Transact-SQL segment should you use for each requirement? To answer, select the appropriate Transact-SQL segments in the answer area.
Hot Area:

Correct Answer:
Box 1: TRY"¦CATCH -
The TRY...CATCH Transact-SQL construct implements error handling for Transact-SQL that is similar to the exception handling in the Microsoft Visual C# and
Microsoft Visual C++ languages. A group of Transact-SQL statements can be enclosed in a TRY block. If an error occurs in the TRY block, control is passed to another group of statements that is enclosed in a CATCH block.
Box 2: RAISERROR(50555, 14, 1 'The update failed.") WITH LOG
We must use RAISERROR to be able to specify the required severity level of 14, and we should also use the LOG option, which Logs the error in the error log and the application log for the instance of the Microsoft SQL Server Database Engine, as this enable a MS MS SQL SERVER alert to be triggered.
Note: RAISERROR generates an error message and initiates error processing for the session. RAISERROR can either reference a user-defined message stored in the sys.messages catalog view or build a message dynamically. The message is returned as a server error message to the calling application or to an associated CATCH block of a TRY"¦CATCH construct.
Incorrect Answers:
Not THROW: THROW does not have a severity parameter.
References:
https://msdn.microsoft.com/en-us/library/ms175976.aspx
https://msdn.microsoft.com/en-us/library/ms178592.aspx

Box 1: TRY"¦CATCH -
The TRY...CATCH Transact-SQL construct implements error handling for Transact-SQL that is similar to the exception handling in the Microsoft Visual C# and
Microsoft Visual C++ languages. A group of Transact-SQL statements can be enclosed in a TRY block. If an error occurs in the TRY block, control is passed to another group of statements that is enclosed in a CATCH block.
Box 2: RAISERROR(50555, 14, 1 'The update failed.") WITH LOG
We must use RAISERROR to be able to specify the required severity level of 14, and we should also use the LOG option, which Logs the error in the error log and the application log for the instance of the Microsoft SQL Server Database Engine, as this enable a MS MS SQL SERVER alert to be triggered.
Note: RAISERROR generates an error message and initiates error processing for the session. RAISERROR can either reference a user-defined message stored in the sys.messages catalog view or build a message dynamically. The message is returned as a server error message to the calling application or to an associated CATCH block of a TRY"¦CATCH construct.
Incorrect Answers:
Not THROW: THROW does not have a severity parameter.
References:
https://msdn.microsoft.com/en-us/library/ms175976.aspx
https://msdn.microsoft.com/en-us/library/ms178592.aspx
send
light_mode
delete
Question #17
DRAG DROP -
You need to create a stored procedure to update a table named Sales.Customers. The structure of the table is shown in the exhibit. (Click the exhibit button.)

The stored procedure must meet the following requirements:
✑ Accept two input parameters.
✑ Update the company name if the customer exists.
✑ Return a custom error message if the customer does not exist.
Which five Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-
SQL segments to the answer area and arrange them in the correct order.
NOTE: More than one order of answer choices is correct. You will receive credit for any of the correct orders you select.
Select and Place:

You need to create a stored procedure to update a table named Sales.Customers. The structure of the table is shown in the exhibit. (Click the exhibit button.)

The stored procedure must meet the following requirements:
✑ Accept two input parameters.
✑ Update the company name if the customer exists.
✑ Return a custom error message if the customer does not exist.
Which five Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-
SQL segments to the answer area and arrange them in the correct order.
NOTE: More than one order of answer choices is correct. You will receive credit for any of the correct orders you select.
Select and Place:

send
light_mode
delete
Question #18
You need to create an indexed view that requires logic statements to manipulate the data that the view displays.
Which two database objects should you use? Each correct answer presents a complete solution.
Which two database objects should you use? Each correct answer presents a complete solution.
- Aa user-defined table-valued function
- Ba CRL function
- Ca stored procedure
- Da user-defined scalar function
Correct Answer:
AC
You can create a database object inside an instance of SQL Server that is programmed in an assembly created in the Microsoft .NET Framework common language runtime (CLR). Database objects that can leverage the rich programming model provided by the common language runtime include aggregate functions, functions, stored procedures, triggers, and types.
AC
You can create a database object inside an instance of SQL Server that is programmed in an assembly created in the Microsoft .NET Framework common language runtime (CLR). Database objects that can leverage the rich programming model provided by the common language runtime include aggregate functions, functions, stored procedures, triggers, and types.
send
light_mode
delete
Question #19
DRAG DROP -
You have two tables named UserLogin and Employee respectively.
You need to create a Transact-SQL script that meets the following requirements:
✑ The script must update the value of the IsDeleted column for the UserLogin table to 1 if the value of the Id column for the UserLogin table is equal to1.
✑ The script must update the value of the IsDeleted column of the Employee table to 1 if the value of the Id column is equal to 1 for the Employee table when an update to the UserLogin table throws an error.
✑ The error message "No tables updated!" must be produced when an update to the Employee table throws an error.
Which five Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-
SQL segments to the answer area and arrange them in the correct order.
Select and Place:

You have two tables named UserLogin and Employee respectively.
You need to create a Transact-SQL script that meets the following requirements:
✑ The script must update the value of the IsDeleted column for the UserLogin table to 1 if the value of the Id column for the UserLogin table is equal to1.
✑ The script must update the value of the IsDeleted column of the Employee table to 1 if the value of the Id column is equal to 1 for the Employee table when an update to the UserLogin table throws an error.
✑ The error message "No tables updated!" must be produced when an update to the Employee table throws an error.
Which five Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-
SQL segments to the answer area and arrange them in the correct order.
Select and Place:

Correct Answer:
A TRY block must be immediately followed by an associated CATCH block. Including any other statements between the END TRY and BEGIN CATCH statements generates a syntax error.
References:
https://msdn.microsoft.com/en-us/library/ms175976.aspx

A TRY block must be immediately followed by an associated CATCH block. Including any other statements between the END TRY and BEGIN CATCH statements generates a syntax error.
References:
https://msdn.microsoft.com/en-us/library/ms175976.aspx
send
light_mode
delete
Question #20
SIMULATION -
You work for an organization that monitors seismic activity around volcanos. You have a table named GroundSensors. The table stored data collected from seismic sensors. It includes the columns describes in the following table:

The database also contains a scalar value function named NearestMountain that returns the name of the mountain that is nearest to the sensor.
You need to create a query that shows the average of the normalized readings from the sensors for each mountain. The query must meet the following requirements:
✑ Include the average normalized readings and nearest mountain name.
✑ Exclude sensors for which no normalized reading exists.
✑ Exclude those sensors with value of zero for tremor.
Construct the query using the following guidelines:
✑ Use one part names to reference tables, columns and functions.
✑ Do not use parentheses unless required.
✑ Do not use aliases for column names and table names.
Do not surround object names with square brackets.


Part of the correct Transact-SQL has been provided in the answer area 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.

Use the Check Syntax button to verify your work. Any syntax or spelling errors will be reported by line and character position.
You work for an organization that monitors seismic activity around volcanos. You have a table named GroundSensors. The table stored data collected from seismic sensors. It includes the columns describes in the following table:

The database also contains a scalar value function named NearestMountain that returns the name of the mountain that is nearest to the sensor.
You need to create a query that shows the average of the normalized readings from the sensors for each mountain. The query must meet the following requirements:
✑ Include the average normalized readings and nearest mountain name.
✑ Exclude sensors for which no normalized reading exists.
✑ Exclude those sensors with value of zero for tremor.
Construct the query using the following guidelines:
✑ Use one part names to reference tables, columns and functions.
✑ Do not use parentheses unless required.
✑ Do not use aliases for column names and table names.
Do not surround object names with square brackets.


Part of the correct Transact-SQL has been provided in the answer area 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.

Use the Check Syntax button to verify your work. Any syntax or spelling errors will be reported by line and character position.
Correct Answer:
Please see explanation
SELECT Average(NormalizedReading), NearestMountain(SensorID)
FROM GroundSensors -
WHERE TREMOR IS NOT 0 AND NormalizedReading IS NOT NULL
GROUP BY NearestMountain(SensorID)
GROUP BY is a SELECT statement clause that divides the query result into groups of rows, usually for the purpose of performing one or more aggregations on each group. The SELECT statement returns one row per group.
References:
https://msdn.microsoft.com/en-us/library/ms177673.aspx
Please see explanation
SELECT Average(NormalizedReading), NearestMountain(SensorID)
FROM GroundSensors -
WHERE TREMOR IS NOT 0 AND NormalizedReading IS NOT NULL
GROUP BY NearestMountain(SensorID)
GROUP BY is a SELECT statement clause that divides the query result into groups of rows, usually for the purpose of performing one or more aggregations on each group. The SELECT statement returns one row per group.
References:
https://msdn.microsoft.com/en-us/library/ms177673.aspx
send
light_mode
delete
All Pages