Skip to content
Advertisement

How to use a value from one stored procedure in another?

I have the following statement in a stored procedure:

Which calls another stored procedure with the following statement inside:

However when I test the call the EXEC outputs the value correctly but it is not assigned to the @Count parameter correctly.

I’ve seen examples or stored procedures used like this, including here but none had a parameter and a return value used (that I could find).

The ID parameter is passed into the second statement which returns a count value used by the first stored procedure – all the info I have read seems to indicate this should work – but it doesn’t the @Count value is always zero, even when the GetItemCount returns always the correct value.

This is in Microsoft SQL Server 2008 if that helps.

Advertisement

Answer

In your stored procedure, are you either

a) Assigning the value of the count to an output parameter:

called as:

or, b) Assigning the count value as the return value:

called as:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement