[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Stored Proc parameter out question

Posted on 2007-09-28
2
Medium Priority
?
263 Views
Last Modified: 2010-03-19
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()
0
Comment
Question by:ALawrence007
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 19978201
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
 
LVL 27

Expert Comment

by:ptjcb
ID: 19978351
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question