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()
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?