34,588
社区成员
发帖
与我相关
我的任务
分享
CREATE PROCEDURE uspGetBillDispenses
@receivebillPerson VARCHAR(50),
@billType VARCHAR(50),
@pageIndex INT,
@pageSize INT,
@recordCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT tb1.* FROM
(SELECT ROW_NUMBER() OVER (ORDER BY PKID) AS id,* FROM BillMgt_BillDispenses
WHERE ReceiverBillPerson LIKE '%'+@receivebillPerson+'%' AND BillType=isnull(@billtype,'')
)tb1
WHERE id BETWEEN (@pageIndex-1)*@pageSize+1 AND @pageIndex*@pageSize
SELECT @recordCount=COUNT(1) FROM BillMgt_BillDispenses
WHERE ReceiverBillPerson LIKE '%'+@receivebillPerson+'%' AND BillType=isnull(@billtype,'')
END
GO
--调用
DECLARE @out INT
EXEC uspGetBillDispenses '@receivebillPerson值','@billType值','@pageIndex值','@pageSize值',@out OUTPUT
SELECT @out
GO
--前提是你要懂得分页,其他的也没啥,就是sql语句了
--你的表自己建,我这里是个实例,一切照搬就行了,
create table t1
(
id int,
Name varchar(50)
)
Create PROCEDURE uspGetBillDIspenses
-- Add the parameters for the stored procedure here
@receivebillPerson varchar(50),
@billType varchar(50),
@pageIndex int,
@pageSize int,
@recordCount int output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select t.* from
(
select ROW_NUMBER() over (order by id) as num,* from t1
where Name = @receivebillPerson /* 其他查询条件照搬 */
) t where num>(@pageIndex -1)*@pageSize and num<=@pageIndex*@pageSize
select @recordCount = COUNT(1) from t1 where Name = @receivebillPerson /* 其他查询条件照搬 */
END
GO