Monday, March 19, 2012

MS SQL records pagination (LIMIT/OFSET)

What is best way to return 1st 20 records, then next 20 records, so on,
dynamically? (MySQL/pgSQL, others have limit/ofset).
Use co-related like this:
http://josephlindsay.com/archives/2005/05/27/paging-results-in-ms-sql-server
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenethowto05.asp
Is there another better way ?
tia,
.V"netsql" <netsql@.roomity.com> wrote in message
news:eI4KJytRGHA.1576@.tk2msftngp13.phx.gbl...
> What is best way to return 1st 20 records, then next 20 records, so on,
> dynamically? (MySQL/pgSQL, others have limit/ofset).
> Use co-related like this:
> http://josephlindsay.com/archives/2005/05/27/paging-results-in-ms-sql-server
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenethowto05.asp
> Is there another better way ?
> tia,
> .V
http://www.aspfaq.com/show.asp?id=2120
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Is there a good SQL answer (for use w/
DataSource/WinForms/DataGrid/SmartClient and not ASP)
like http://dev.mysql.com/doc/refman/5.0/en/select.html ?
.V
David Portas wrote:
> "netsql" <netsql@.roomity.com> wrote in message
> news:eI4KJytRGHA.1576@.tk2msftngp13.phx.gbl...
>> What is best way to return 1st 20 records, then next 20 records, so on,
>> dynamically? (MySQL/pgSQL, others have limit/ofset).
>> Use co-related like this:
>> http://josephlindsay.com/archives/2005/05/27/paging-results-in-ms-sql-server
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenethowto05.asp
>> Is there another better way ?
>> tia,
>> .V
> http://www.aspfaq.com/show.asp?id=2120
>|||"netsql" <netsql@.roomity.com> wrote in message
news:4415DE37.2060805@.roomity.com...
> Is there a good SQL answer (for use w/
> DataSource/WinForms/DataGrid/SmartClient and not ASP)
> like http://dev.mysql.com/doc/refman/5.0/en/select.html ?
>
Read the whole article. Six of those techniques are pure SQL and don't use
ASP.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

No comments:

Post a Comment