ALTER PROCEDURE [dbo].[GetAllCount]
AS
BEGIN
declare @countsql varchar(100);
declare @allcount bigint=0; /*总行数*/
declare @count int; /*当前表行数*/
declare @currentTemp int; /*起始迭代数*/
set @currentTemp=10000;
while(@currentTemp<=99999)
begin
set @countsql='select @count=count(QQNumber) from tab_'+convert(varchar(10),@currentTemp);
exec sp_executesql @countsql,N'@count int output',@count output;
set @allcount=@allcount+@count;
end
return @allcount;
END