|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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, |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
Thanks for all the suggestion. I think using programming level to move the cursor to the desired offset is the most portable one.
|
|
#5
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > SQL Server Select using offset |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|