sql分页代码

//三种sql分页语句

SELECT TOP 分页尺寸 *
FROM
        (
        SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* FROM Blobs
        ) A
WHERE RowNumber > 分页尺寸*(页数-1)

SELECT TOP 分页尺寸 *
FROM Blobs
WHERE id NOT IN
          (
          SELECT TOP (分页尺寸 *(页数-1)) id FROM Blobs ORDER BY id
          )
ORDER BY id

select * from
(
    select Row_Number() over (order by id) AS RowNumber,* from Blobs
) t
where RowNumber between 页数 * 分页尺寸+1 and (页数+1)*分页尺寸

 

posted @ 2014-11-18 14:06  梦锁湘江  阅读(122)  评论(0编辑  收藏  举报