USE Northwind GO -- Create a procedure that takes one input parameter -- and returns one output parameter and a return code. CREATE PROCEDURE SampleProcedure @EmployeeIDParm INT, @MaxQuantity INT OUTPUT AS -- Declare and initialize a variable to hold @@ERROR. DECLARE @ErrorSave INT SET @ErrorSave = 0 -- Do a SELECT using the input parameter. SELECT FirstName, LastName, Title FROM Employees WHERE EmployeeID = @EmployeeIDParm -- Save any nonzero @@ERROR value. IF (@@ERROR <> 0) SET @ErrorSave = @@ERROR -- Set a value in the output parameter. SELECT @MaxQuantity = MAX(Quantity) FROM [Order Details] IF (@@ERROR <> 0) SET @ErrorSave = @@ERROR -- Returns 0 if neither SELECT statement had -- an error; otherwise, returns the last error. RETURN @ErrorSave GO
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)