create procedure usp_ProductByCategory
(
@categoryID int,
@beginIndex int,
@endIndex int,
@docount bit
)
as
if(@docount=1)--说明只做统计计数
begin
select count(*) from ViewProduct where categoryid=@categoryid
end
else
begin
with tempbl as (select row_number() over (order by AddDate desc) as rownum,* from ViewProduct where cateoryid=@categoryId)
select * from tempbl where rownum between @beginindex and @endindex
end