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

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 and END statements.
Part of the correct T-SQL statement has been provided in the answer area. Provide the complete code.

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 and END statements.
Part of the correct T-SQL statement has been provided in the answer area. Provide the complete code.

Answer: See the explanation.

Explanation:
CREATE PROCEDURE usp_Customers @Count int
SELECT TOP(@Count)
Customers.LastName
FROM Customers
ORDER BY Customers.LastName



Leave a Reply 4

Your email address will not be published. Required fields are marked *


33u

33u

‘AS’ is missed before SELECT

Kevin

Kevin

CREATE PROCEDURE usp_Customers @Count int
AS
SET NOCOUNT ON;
Select Top (@Count) LastName
FROM Customers
ORDER BY LastName;

eandri

eandri

as it is the answer gives Syntax error next to TOP!

Mark

Mark

I would agree with Kevin:

CREATE PROCEDURE Usp_Customers
@Count INT
AS
SET NOCOUNT ON; — Important since question asks to reduce counting
SELECT TOP (@Count) ContactName
FROM Sales.Customers
ORDER BY ContactName;