Hi Jack,
Thanks for your reply, your guess is right.
Please tell me how to use the example you wrote
Exec GetCommonItemCount @cnt = @cnt Output
Do you mean i should define an additional parameter to GetCommonItemCount and make the sp return the result in that parameter to the original SP?
Jack Corbett (10/1/2014)
Luis Cazares (10/1/2014)
Most people won't download RAR files. Please post the code using IFCode tags [ code="sql"][/code] or at least text files. We would also need DDL and sample data. Please, read the article linked in my signature to know what we need.+1.
I wouldn't download a RAR file that gets posted by someone I don't know personally and without your code there isn't any way to see what your issue is. My best guess is that you are trying something like this:
EXEC @cnt = GetCommonItemCount
But what that returns is the return value of the stored procedure which is 0 when executed without errors and not set directly, not any data from it. You either want something like this:
Declare @countTable Table(Column list)
Insert into @countTable (Column list matching the order in the sp)
Exec GetCommonItemCount
Or you want @cnt to be an output parameter in the stored procedure and call it like this:
/* I'm assuming you already have declared @cnt */
Exec GetCommonItemCount @cnt = @cnt Output
Select @cnt /* or use @cnt how you need to */