Link to home
Start Free TrialLog in
Avatar of ALawrence007
ALawrence007

asked on

Stored Proc parameter out question

Hi,
I have a stored proc that I need to get a parameter out (the scope_Identity). When I run my Proc I get an error saying 'expects parameter '@ID', which was not supplied'. Can someone tell me what I am doing wrong in my proc?
ALTER PROCEDURE [Master]
@CustomerId int,
@Total money,                  
@ID INT OUTPUT        
AS
INSERT INTO MyTable
([CustomerID]
,[Total])
VALUES
(@CustomerID
,@Total)
SET @ID = SCOPE_IDENTITY()
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am confused. I do not understand your data structure.

You have MyTable, which has two columns. CustomerID is an integer.

Do you have it set as an identity column? An identity column would automatically add the next available number to the column.

In your Master procedure, you insert a value that is a parameter - @CustomerID. If the column is an identity column, then why are you inserting a value?

Then you capture the @ID value by using Scope_Identity(). What value do you want to capture?