1. 利用row_number()
语法:select 字段1,.. row_number() over (order by 字段) as rowno from table
where 条件 and rowno >(pageIndex-1)*pageSize and rowno<=pageIndex*pageSize
select TarHandPhone from (select TarHandPhone ,ROW_NUMBER() over(order by id )as rowno from b
)m2 where rowno > (@pageIndex-1)*@pageSize and rowno<= @pageIndex*@pageSize
2.建临时表
declare @indextable table(indexrow int identity,pid int)
insert into @indextable select ID from SMS_Message_Log2014_7_8 where MainID='19759'
select 字段1,... from 表名 a
inner join @indextable b on a.ID=b.pid
where 条件 and b.indexrow between @pagsize*(@pagindex-1)+1 and @pagindex*@pagsize