We help IT Professionals succeed at work.
Get Started

return @rowcount from stored procedure

836 Views
Last Modified: 2016-06-03
hello,

I am somwhat new to stored procedures. What I want is to return the rowcount from the stored procedure to vba.

Here is my stored procedure code
GO
-- =============================================
-- Author:	aebea
-- Create date:        05/13/2011
-- Description:	returns recordset based on parameters 
-- =============================================
ALTER PROCEDURE [dbo].[sp_getRecIdsForProcessing]
	-- Add the parameters for the stored procedure here
	@act varchar(50),
	@beginDate datetime,
	@endDate datetime,
	@processStep int,
	@Rowcount int output	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	DECLARE @firstDate as datetime
	DECLARE @lastDate as datetime
	
	SET @firstDate = (SELECT CONVERT(DATETIME,@beginDate,101))
	SET @lastDate = (SELECT CONVERT(DATETIME,@endDate,101))	


		
    -- Insert statements for procedure here
    if @act = '*' 
			begin
				SELECT		tbl_ProcessTracking.RecID, tbl_ProcessTracking.OnThisProcStep, tbl_ProcessTracking.AsOf, tbl_MasterFile.PDFName, tbl_MasterFile.Act, 
							tbl_MasterFile.ActDate, tbl_MasterFile.FS_Name, tbl_MasterFile.DateReceived, tbl_MasterFile.CaseID, tbl_MasterFile.SheetComment, 
							tbl_MasterFile.Del_Rec
				FROM        tbl_MasterFile INNER JOIN
							tbl_ProcessTracking ON tbl_MasterFile.RecID = tbl_ProcessTracking.RecID
				WHERE		[ActDate] between @firstdate and @lastdate
							and [OnThisProcStep]=@processStep-1
			end
		else
			begin
				SELECT		tbl_ProcessTracking.RecID, tbl_ProcessTracking.OnThisProcStep, tbl_ProcessTracking.AsOf, tbl_MasterFile.PDFName, tbl_MasterFile.Act, 
							tbl_MasterFile.ActDate, tbl_MasterFile.FS_Name, tbl_MasterFile.DateReceived, tbl_MasterFile.CaseID, tbl_MasterFile.SheetComment, 
							tbl_MasterFile.Del_Rec
				FROM        tbl_MasterFile INNER JOIN
							tbl_ProcessTracking ON tbl_MasterFile.RecID = tbl_ProcessTracking.RecID
				WHERE		[ActDate] between @firstdate and @lastdate
							and [Act] = @act
							and	[OnThisProcStep]=@processStep-1
			end
			
	set @rowcount = @@rowcount
	RETURN @@rowcount
END

Open in new window


You can see i have set up a parameter called @rowcount. How do I set up my vba code to retrieve that value?

thanks!
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2012
Commented:
This problem has been solved!
Unlock 1 Answer and 16 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE