Below is the eg. of Stored Procedure with Output Parameter
CREATE PROCEDURE [dbo].[InsertCustomer]
(
@LastName varchar(50),
@FirstName varchar(50),
@Address varchar(50),
@City varchar(50),
@State char(2),
@ZIP varchar(10),
@CustomerID int OUTPUT,
@Modified timestamp OUTPUT
)
AS
SET NOCOUNT ON;
-- Inserts a Customer row
INSERT INTO Customer
( LastName, FirstName, Address, City, State, ZIP )
VALUES
( @LastName, @FirstName, @Address, @City, @State, @ZIP ) ;
IF @@ROWCOUNT>0 AND @@ERROR=0 -- Checks if the last statement produced an error
-- Selects the primay key value and the generated timestamp which is put back into the dataset
SELECT @CustomerID = CustomerID,
@Modified = Modified
FROM Customer
WHERE (CustomerID = SCOPE_IDENTITY());
RETURN
Rajasekhar0544, if this helps please login to Mark As Answer. | Alert Moderator