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()
ALawrence007Asked:
Who is Participating?
 
Aneesh RetnakaranDatabase AdministratorCommented:
in order to execute it first  declare a variable to hold the outpu

DECLARE @Res INT
EXEC {master] 1,2, @Res OUT
SELECT @Res
0
 
ptjcbCommented:
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?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.