I am new to SQL Server. From EE contributions I now have an SP that will return the number of records in a Table: Here it is:
/****** Object: StoredProcedure [dbo].[spMJORecCount] Script Date: 9/16/2015 10:17:59 AM ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER PROCEDURE [dbo].[spMJORecCount] (@TableName varchar(75))
DECLARE @SQL varchar(250);
SELECT @SQL = 'SELECT Count(*) from ' + @TableName;
For large volume transactions I use returned record count number to show the user a status of the processing, "Processing 4,123 of 12,345"
In many cases I don't want to know how many records are in the entire table but how many are in a SQL statement or perhaps even a query ,
For example I have a MS Access 2013 VBA processing loop driven by this sql statement:
"Select * from " & inputTable & " Where [Year] = 2015"
I would like a stored procedure that would return the count of records in the evaluated Select statement.
Some processing loops are drive by predefined queries such a "qrySelectActiveRecords"
I would also like a stored procedure to return the count of records in the evaluated query.
Best of all would be one stored procedure to handle all three situations.