I have the following statement in a Stored Procedure:
DECLARE @Count INT
EXEC @Count = GetItemCount 123
SELECT @Count
Which calls another stored procedure with the following statement inside:
SELECT COUNT(Item) FROM tblItem WHERE ID = @ID
However when I test the call the EXEC outputs the value correctly but it is not assigned to the @Count Variable 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 StoredProcedure - all the info I have read seems to indicate this should work - but it doesn't the @Count value is aways zero, even when the GetItemCount returns always the correct value.
This is in Microsoft SQL Server 2008 if that helps.