CREATE procedure getQueryPageitems
@totalItemCount int,
@pageNumber int,
@pageSize int
as
declare @numberOfItemToSelectForPage int
declare @totalItemsToSel int
declare @query nvarchar(4000)
if(@pageSize*@pageNumber <= @totalItemCount)
begin
set @numberOfItemToSelectForPage = @pageSize
set @totalItemsToSel = @pageSize*@pageNumber
end
else
begin
set @numberOfItemToSelectForPage = @totalItemCount - (@pageSize*(@pageNumber -1))
set @totalItemsToSel = @totalItemCount
end
begin
select @query = 'select * from(select top ' + cast(@numberOfItemToSelectForPage as varchar(10))
+ ' * from (select top ' + cast(@totalItemsToSel as varchar(10))
+ ' * from (select * from Query where Leedflag=1) tbl1
order by EntryDate desc)tabl2 order by EntryDate asc)tbl3 order by EntryDate desc'
end
--print @query
exec (@query)
GO
@totalItemCount int,
@pageNumber int,
@pageSize int
as
declare @numberOfItemToSelectForPage int
declare @totalItemsToSel int
declare @query nvarchar(4000)
if(@pageSize*@pageNumber <= @totalItemCount)
begin
set @numberOfItemToSelectForPage = @pageSize
set @totalItemsToSel = @pageSize*@pageNumber
end
else
begin
set @numberOfItemToSelectForPage = @totalItemCount - (@pageSize*(@pageNumber -1))
set @totalItemsToSel = @totalItemCount
end
begin
select @query = 'select * from(select top ' + cast(@numberOfItemToSelectForPage as varchar(10))
+ ' * from (select top ' + cast(@totalItemsToSel as varchar(10))
+ ' * from (select * from Query where Leedflag=1) tbl1
order by EntryDate desc)tabl2 order by EntryDate asc)tbl3 order by EntryDate desc'
end
--print @query
exec (@query)
GO
2 comments :
good thinking please provide cs part of this....
Post a Comment