MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 5th, 2004, 12:23 PM
lueg66 lueg66 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 13 lueg66 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 27 sec
Reputation Power: 0
Limiting Result for Pagination

Hello,

We are migrating from VB6/MySQL to VB6/MS SQL.

The application retrieves limited records for paginated results.
This way we can access large databases, but only return rows for one screen.

For example:
Select row 1 - 10, then 11 - 20 then 21 to 30 etc.

With MySQL we can use LIMIT and OFFSET and it works great.
MySQL
SELECT <columns> FROM <tables> [WHERE <condition>] [ORDER BY <columns>]
[LIMIT [offset,]howmany>]

Does anybody know how we can do something similar with MS SQL?

Any feedback is appreciated!

Thank you,

Edi

Reply With Quote
  #2  
Old August 13th, 2004, 11:00 AM
cell-gfx cell-gfx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 13 cell-gfx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0

Reply With Quote
  #3  
Old August 17th, 2004, 07:34 PM
lueg66 lueg66 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 13 lueg66 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 27 sec
Reputation Power: 0
Hello cell-gfx!

I found basically the same. It works fine.

Thanks for your Help

Edi

SELECT * FROM (
SELECT TOP x * FROM ( -- (x = LinesPerPage
SELECT TOP z ProductID -- (z = CurrentPage * LinesPerPage)
FROM Products
ORDER BY ProductID ASC
) AS foo ORDER BY ProductID DESC -- ('foo' may be anything "One
To Current Page)
) AS baz -- ('baz' may be anything "Current
Page Reverse Order")
ORDER BY ProductID ASC -- ("Current Page in Order"

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Limiting Result for Pagination


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway