Anda tidak mendeklarasikan parameter, tetapi variabel lokal. Untuk mendeklarasikannya seperti yang Anda inginkan:
CREATE PROCEDURE pOrders (@enteredClientID varchar(20))
AS
DECLARE @Results table (ClientID varchar(20), Num_orders int);
SET NOCOUNT ON;
-- Get all the order from the client
INSERT INTO @Results
SELECT ClientID, sum(Num_orders)
FROM Orders O
WHERE O.ClientID = @enteredClientID
GROUP BY O.ClientID);
-- Insert the orders into the results table --
SELECT *
FROM @Results;
GO;
Sebut saja:
exec pOrders @enteredClientID = 'ABC123456789'
atau cukup
exec pOrders 'ABC123456789'