declare @Sql nvarchar(1000)
set @Sql = 'select top ('+CONVERT(varchar(50),@pageSize)+') * from '+@tableName+' where '+@ID+' not in(select top(('+CONVERT(varchar(50),@pageIndex)+'-1)*'+CONVERT(varchar(50),@pageSize)+') '+@ID+' from '+@tableName+' where RecEmail='+@RecEmail+') and RecEmail='+@RecEmail+'';
set @Sql += 'select @row=COUNT(1) from '+@tableName+' where RecEmail='+@RecEmail+'';
--系统存储过程
exec sp_executesql @Sql,N'@row int out',@rowCount out
END
GO
declare @rowCount int
exec Email_Pager 'Email','ID','songxinlei@1505.com',5,2,@rowCount out
select @rowCount
那是因为你的sql代码混乱导致,你应该定义几个变量,比如一个是查询出所有列的变量,再一个是进行查询的变量以及其他!