declare @tableName varchar(50)
declare @pageIndex int
declare @pageSize int

set @pageIndex = 3
set @pageSize = 20

declare  @tempTable table
(
 ID int Identity,

 ajid varchar(50)
)

declare @maxCount int
set @maxCount  = @pageIndex + @pageSize -1

--set ROWCOUNT  @maxCount

 

insert into @tempTable
SELECT id FROM AJ_AQJDSB
order by id


select aj.* from @tempTable t
inner join  @tableName  t2
on t2.id=t.ajid
where t.id between @pageIndex and @maxCount

posted on 2009-09-27 11:15  新郎  阅读(136)  评论(0编辑  收藏  举报