70-461 Querying Microsoft SQL Server 2012

Loading demo links...

Showing 4–6 of 15 questions

Question 4

SIMULATION

You have a database named Sales that contains the tables shown in the exhibit. (Click the Exhibit button.)

You have an application named Appl. You have a parameter named @Count that uses the int data type. App1 is configured to pass @Count to a stored procedure.

You need to create a stored procedure named usp_Customers for App1 that returns only the number of rows specified by the @Count parameter.

The solution must NOT use BEGIN, END, or DECLARE statements.

Part of the correct Transact-SQL statement has been provided in the answer area. Complete the Transact-SQL statement

Answer is in the explanation below.

Question 5

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 have a SQL database that contains a table named Products.

You are implementing a stored procedure that retrieves the list of products, performs custom business logic and then retrieve the list of products again.

The custom business logic in the stored procedure does not modify data from the Products table.

The stored procedure contains the following:

You need to complete line 01 of the stored procedure to ensure that when the transaction occurs, the data read from the SELECT * FROM Products statement on line 05 is identical to the data read from the SELECT * FROM Products statement on line 10. The solution must maximize concurrency.

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.

Answer is in the explanation below.

Question 6

You develop a Microsoft SQL Server database.

You need to create and call a stored procedure that meets the following requirements:

Accepts a single input parameter for CustomerID. Returns a single integer to the calling application.

Which two Transact-SQL statements should you use? Each correct answer presents part of the solution.

Select all that apply, then click Submit answer.

  • CREATE PROCEDURE dbo.GetCustomerRating
    @CustomerID INT,
    @CustomerRating INT OUTPUT
    AS
    SET NOCOUNT ON
    SELECT @CustomerRating = CustomerOrders/CustomerValue
    FROM Customers
    WHERE CustomerID = @CustomerID
    RETURN
    GO

  • EXECUTE dbo.GetCustomerRating 1745

  • DECLARE @CustomerRatingByCustomer INT
    DECLARE @Result INT
    EXECUTE @Result = dbo.GetCustomerRating
    1745,
    @CustomerRatingByCustomer

  • CREATE PROCEDURE dbo.GetCustomerRating
    @CustomerID INT,
    @CustomerRating INT OUTPUT
    AS
    SET NOCOUNT ON
    SELECT @Result = CustomerOrders/CustomerValue
    FROM Customers
    WHERE CustomerID = @CustomerID
    RETURN @Result
    GO

  • DECLARE @CustomerRatingByCustomer INT
    EXECUTE dbo.GetCustomerRating
    @CustomerID = 1745,
    @CustomerRating = @CustomerRatingByCustomer OUTPUT

  • CREATE PROCEDURE dbo.GetCustomerRating
    @CustomerID INT
    AS
    DECLARE @Result INT
    SET NOCOUNT ON
    SELECT @Result = CustomerOrders/CustomerValue
    FROM Customers
    WHERE CustomerID = @CustomerID