2005 ALTERprocedure[dbo].[GetProductsPagedAndSorted]( @sortExpressionnvarchar(20), @startRowIndexint, @maximumRowsint
) as iflen(@sortExpression)=0 set@sortExpression='productid' declare@sqlnvarchar(4000) --declare @sortExpression nvarchar(20),@maximumRows int,@startRowIndex int
--set @sortExpression='productid'
--set @startRowIndex=11
--set @maximumRows=10 set@sql= 'select * from '+ '(select productid,productname,p.supplierid,p.categoryid,quantityperunit,
unitprice,unitsinstock,unitsonorder,reorderlevel,discontinued,
c.categoryname as categoryname,s.companyname as suppliername, ROW_NUMBER() over(order by ' +@sortExpression+')
as RowRank from products p
inner join categories as c on p.categoryid=c.categoryid
inner join suppliers as s on p.supplierid=s.supplierid) as tempTable'+ ' where Rowrank>'+convert(nvarchar(3), @startRowIndex)+' and rowrank<='+
(convert(nvarchar(10), @startRowIndex+@maximumRows))