Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:09:38+00:00 2026-06-10T20:09:38+00:00

Possible Duplicate: Equivalent of LIMIT and OFFSET for SQL Server? I am working on

  • 0

Possible Duplicate:
Equivalent of LIMIT and OFFSET for SQL Server?

I am working on a table which currently contains 2500 rows, and will be much more and more in future.

I am using jqgrid to display the records from the database .

Whenever the grid is loading, I am retrieving the top 500 rows from the database. However when I am started using pagination in the grid, the number of records is adding.

Example : first the number of rows is TOP 100, then going onto the next page its increased to TOP 200 and so on in the query.

Now I want a solution to avoid this issue such that I can limit the rows instead of retrieving top n rows based on the grid. Say using a range or LIMIT

Example

When I am navigating to next page in grid, instead of TOP 200 rows I want to fetch rows from 101 to 200

 select top 500
        exe.id,
        bat.BName,
        bat.tid,
        bat.freq,
        exe.status,
        exe.Msg,
        exe.time,
        exe.Fi
    from
       XXX exe,
        YYY bat 
    where
        exe.id=bat.id   
    order by     
        CONVERT(VARCHAR(10),
        exe.time,
        120) DESC,
        exe.status,
        exe.id DESC

Please guide me in this, as I am new to jQGrid and not much aware how to handle this DB related stuff

I also referred few links in Stackoverflow but can’t understand

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:09:40+00:00Added an answer on June 10, 2026 at 8:09 pm

    You can use ROW_NUMBER(), the row_number() is not assigned until you query the data so if you want to retrieve the data by the row_number() value, then you will need to use CTE or a sub-select to get the value for use in a WHERE clause.

    SELECT *
    FROM
    (
      select  exe.id,
            bat.BName,
            bat.tid,
            bat.freq,
            exe.status,
            exe.Msg,
            exe.time,
            exe.Fi,
            row_number() over(order by CONVERT(VARCHAR(10), exe.time, 120) DESC,
                       exe.status, exe.id DESC) rn
      from XXX exe,
           YYY bat 
      where exe.id=bat.id  
    ) x
    WHERE rn between 101 and 200
    

    I would also suggest a change in your JOIN syntax to use ANSI syntax:

    SELECT *
    FROM
    (
      select  exe.id,
            bat.BName,
            bat.tid,
            bat.freq,
            exe.status,
            exe.Msg,
            exe.time,
            exe.File,
            row_number() over(order by CONVERT(VARCHAR(10), exe.time, 120) DESC,
                       exe.status, exe.id DESC) rn
      from XXXexe
      INNER JOIN  YYY bat 
         ON exe.id=bat.id  
    ) x
    WHERE rn between 101 and 200
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Equivalent of LIMIT and OFFSET for SQL Server? this is a mysql
Possible Duplicate: Does SQL Server 2005 have an equivalent to MySql’s ENUM data type?
Possible Duplicate: Equivalent of SQL ISNULL in LINQ? I am recently migrated from ADO.Net
Possible Duplicate: Is there an equivalent of ‘which’ on windows? Failed to find it
Possible Duplicate: How do I limit the number of rows returned by an oracle
Possible Duplicate: jQuery convert line breaks to br (nl2br equivalent) Currently I add <BR>
Possible Duplicate: remove_if equivalent for std::map Yesterday i wrote a program, which use multiset
Possible Duplicate: Alphabetic equivalent of PHP is_numeric If you check if the data is
Possible Duplicate: remove_if equivalent for std::map I have a set of strings: set <wstring>
Possible Duplicate: PHP ToString() equivalent I get this error: Catchable fatal error: Object of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.