Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 30th, 2003, 06:46 PM
reynardmh reynardmh is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 reynardmh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQL Server Select using offset

Hi I'm pretty new to Sql server
Just wondering if it is possible to return a select result from a specific offset?

For example In PostgreSQL you can do that:
SELECT * FROM table
OFFSET 10 LIMIT 10
which will return 10 rows starting from the 10th rows.

I have tried to search on 2 sql server books but only find TOP N as the LIMIT N equivalent, but not OFFSET.
I guess you can do that in programming level, by only displaying the data from specific rows. but that means you have to fetch all the data that you don't even need.
Any suggestion would be helpful.
thanks,

Reply With Quote
  #2  
Old October 1st, 2003, 08:30 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Weird. You'd think that'd be pretty easy to specify. See if the following link helps you out at all:

http://forums.devshed.com/archive/95/2003/9/3/85059

Reply With Quote
  #3  
Old October 1st, 2003, 09:18 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 7
If you don't want to order by the identity column, you'll have to use a temporary table. See this article for a good example using a Stored Procedure.

http://www.aspfaq.com/show.asp?id=2120

I think SQL Server doesn't support the Offset because of the way that the ASP.NET data objects work.

Reply With Quote
  #4  
Old October 2nd, 2003, 02:12 PM
reynardmh reynardmh is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 reynardmh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for all the suggestion. I think using programming level to move the cursor to the desired offset is the most portable one.

Reply With Quote
  #5  
Old October 3rd, 2003, 01:48 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Check out this article from 4guys on paging records (i.e. requesting records from an offset, server-side).
http://www.aspfaqs.com/webtech/062899-1.shtml
It should have enough theory in there for you to adapt for your specific use. You are right to want to perform the work on the server-side first.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > SQL Server Select using offset


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 4 hosted by Hostway
Stay green...Green IT