2007년 08월 16일
별난 방법 : Paging by MS-SQLServer (Not In을 사용하지 않음)
User-Specific Records
To provide paging through user-specific data, you can use SELECT TOP with nested queries. The main advantages of this approach is that it does not require a unique key column of any sort and it also supports advanced navigation, where the user is able to move to the next, previous, first, and last pages, and is also able to move to a specific page.
The following pseudocode illustrates this technique.
SELECT TOP CustomerID,CompanyName,ContactName,ContactTitle
FROM
(SELECT TOP
CustomerID,CompanyName,ContactName,ContactTitle
FROM
Customers AS T1 ORDER BY ContactName DESC)
AS T2 ORDER BY ContactName ASC
The inner SELECT statement selects a set of rows in descending order based (in this example) on the ContactName column. The number of rows selected is equal to the current page number times the page size. The outer SELECT statement then selects the top n rows, where n is the page size, and presents the data in ascending order based on the ContactName column.
The following code shows the above pseudocode implemented as a stored procedure that can be used to page through the Customers table in the Northwind database.
출처 : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenethowto05.asp
To provide paging through user-specific data, you can use SELECT TOP with nested queries. The main advantages of this approach is that it does not require a unique key column of any sort and it also supports advanced navigation, where the user is able to move to the next, previous, first, and last pages, and is also able to move to a specific page.
The following pseudocode illustrates this technique.
SELECT TOP
FROM
(SELECT TOP
CustomerID,CompanyName,ContactName,ContactTitle
FROM
Customers AS T1 ORDER BY ContactName DESC)
AS T2 ORDER BY ContactName ASC
The inner SELECT statement selects a set of rows in descending order based (in this example) on the ContactName column. The number of rows selected is equal to the current page number times the page size. The outer SELECT statement then selects the top n rows, where n is the page size, and presents the data in ascending order based on the ContactName column.
The following code shows the above pseudocode implemented as a stored procedure that can be used to page through the Customers table in the Northwind database.
출처 : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenethowto05.asp
# by | 2007/08/16 08:26 | 트랙백





☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]