Hi All,
I want to fetch records from a table in my sql server database in parts. Like, in one query I want to see first 1000 records, in next query next 1000 records. Likewise..
Is it possible with sql server ? I am using sql server 2008. While googling, I found LIMIT clause for mysql, but it does not work for sql server. Please help.
Loading
Dorababu MekaPosted May 4, 2011, 9:20 AM
First 1000 records:
General solution (supports offset)
Sam HobbsPosted May 4, 2011, 5:23 PM
Vijay YadavPosted May 4, 2011, 9:35 AM
Dorababu MekaPosted May 4, 2011, 9:34 AM
Mark as answer
Suhani ModyPosted May 4, 2011, 9:31 AM
Suhani ModyPosted May 4, 2011, 9:17 AM
Suhani ModyPosted May 4, 2011, 9:16 AM
what about next 1000 records ? ;)
Dorababu MekaPosted May 4, 2011, 9:08 AM
select top 1000 * from tblname where condition
select top 2000 * from tblname where condition minus select top 1000 * from tblname where condition
Vijay YadavPosted May 4, 2011, 9:05 AM
You are right LIMIT clause doesn't work for Sql as it work with MySql as far as i am concerned.
I think it can be done by using loop, while fecthing the records from the database you can apply your logic if the record reach to the 1000th record you can break the loop and then you can fetch the next 1000 record.