Jump to content

Archived

This topic is now archived and is closed to further replies.

ober

LIMIT for MSSQL?

Recommended Posts

I know you can use the LIMIT clause in MySQL to grab a specific group of records from a MySQL table, but I'm using MSSQL and I need to do the same thing. I know about the TOP function, but I'm not sure how to go about grabbing the TOP x records starting at record y.

I have groups of 12000+ records in a table and I'm graphing all the records. They will have the option to zoom in on the graph and I need to be able to go back and grab from x to y.

Any ideas? The only other thing I was thinking of was doing some math on the ID value (auto-increment).

Share this post


Link to post
Share on other sites
Just in case anyone else ever digs this thread back up or searches for it, I did find an answer:

[a href=\"http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=850&lngWId=5\" target=\"_blank\"]http://www.planet-source-code.com/vb/scrip...Id=850&lngWId=5[/a]

I modified it to fit my application and it works like a charm. Obviously it's very bloated compared to the LIMIT clause, but it works.

Share this post


Link to post
Share on other sites
Also to emulate LIMIT 20,10

[code]SELECT TOP 10 * FROM mssqltable
WHERE id NOT IN (SELECT TOP 20 id FROM mssqltable)[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.