RowNumber() 이용 시
-------------------------------------------------------------------------------------------------------
declare @PageRows INT = 10
declare @PageNo INT = 100
select a.*
from (select *
,row_number() over (order by PostCode) as RowNo
,count(*) over() as totcnt
from PostCode ) a
where RowNo between ((@PageNo-1)*@PageRows)+1 AND @PageRows * @PageNo
Offset fetch 이용 (Sql Server 2012 이상 )
-------------------------------------------------------------------------------------------------------
declare @PageRows INT = 10
declare @PageNo INT = 100
select *
,row_number() over (order by PostCode) as RowNo
,count(*) over() TotCnt
from PostCode
Order by PostCode
offset ((@PageNo-1)*@PageRows) rows fetch next @PageRows rows only
;
MS SQL Server DB 사용량, Table Size (0) | 2021.01.04 |
---|---|
SQL Server Lock 확인 및 IP추적 (0) | 2021.01.04 |
SQL Server 인덱스 리빌드 (0) | 2021.01.04 |
MS SQL Server 테이블 건수 용량 확인 쿼리 (0) | 2021.01.04 |
쿼리 실행 순서 (0) | 2021.01.04 |