Andrew
You are confused. This undocumented stored procedure does not return OUTPUT
parameter
You will probably want to look at below example from the BOL
CREATE PROCEDURE get_sales_for_title
@title varchar(80), -- This is the input parameter.
@ytd_sales int OUTPUT -- This is the output parameter.
AS
-- Get the sales for the specified title and
-- assign it to the output parameter.
SELECT @ytd_sales = ytd_sales
FROM titles
WHERE title = @title
RETURN
GO
The following program executes the stored procedure with a value for the
input parameter and saves the output value of the stored procedure in the
@ytd_sales_for_title variable local to the calling program.
-- Declare the variable to receive the output value of the procedure.
DECLARE @ytd_sales_for_title int
-- Execute the procedure with a title_id value
-- and save the output value in a variable.
EXECUTE get_sales_for_title
"Sushi, Anyone?", @ytd_sales = @ytd_sales_for_title OUTPUT
-- Display the value returned by the procedure.
PRINT 'Sales for "Sushi, Anyone?": ' +
convert(varchar(6),@ytd_sales_for_title)
GO
Sales for "Sushi, Anyone?": 4095
[quoted text, click to view] "Andrew Robinson" <cyn3rgy@hotmail.com> wrote in message
news:2e41d4e0.0412082138.5b115bd8@posting.google.com...
> Hi All
>
> I've written this stored procedure in SQL 2000. When I run it, I get
> an error that I've not declared a variable. Full error is:
>
> Inventory: Counting history, ID = 151
> Server: Msg 137, Level 15, State 2, Line 1
> Must declare the variable '@idHistory'. (I get this line for each
> table)
>
>
> this is my stored procedure code - I'm new to this so apologies for
> any dodgy code :)
>
> CREATE PROCEDURE [dbo].[InventoryCountFromidHistory] @idHistory INT
> AS
> IF (@IDHistory IS NULL)
> RETURN -- No target, we can do nothing
>
> -- Drop a message in the Windows Application log
> DECLARE @msg nvarchar(1024)
> SET @msg = 'Inventory: Counting history, ID = ' + STR(@IDHistory)
> PRINT @msg
>
> EXEC sp_MSforeachtable "Select Count(idHistory)as [?] from ? Where
> idHistory=@idHistory"
> GO
>
> Can anyone help me out, I'm probably doing something totally stupid :)
>
> thanks
>
> Andrew