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 6740949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:40:02+00:00 2026-05-26T11:40:02+00:00

I have a very strange bug with sql server 2008: To display a pager

  • 0

I have a very strange bug with sql server 2008:

To display a pager in a CRUD application details view, I make a sql request to get previous and next record relative to the current, it works well except when ordering on a DECIMAL column, I can reduce the problem to that query (FTE is decimal(18,2)):

WITH [IndexedRows] AS (
    SELECT 
        [ContactId], 
        [ContactCode],
        [FTE],
        [EmployeeName], 
        ROW_NUMBER() OVER ( ORDER BY [FTE] ASC ) AS [RowIndex]
    FROM   
        [Vw_HrEmployee]
)

/* 1. I can see ContactId 1109 is rowindex 7 */
/*SELECT * FROM [IndexedRows];*/

/* 2. Get the RowIndex, it returns 7 */
/*SELECT [RowIndex] 
FROM   [IndexedRows] 
WHERE  [ContactId] = 1109;*/

/* 3. Why it doesn't returns ContactId 1109 ??? */
SELECT [ContactId], 
       [EmployeeName] 
FROM   [IndexedRows] 
WHERE [RowIndex] = 7;

I get the contactId of another person who have the same FTE value, but I don’t understand why the WHERE rowindex don’t return the correct row (if I display IndexedRows, it looks good!).

I don’t think it’s revelant but Vw_HrEmployee is a View.

Any help/idea/workaround to solve that is welcome,

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-05-26T11:40:03+00:00Added an answer on May 26, 2026 at 11:40 am

    This is a guess, but if you have duplicate values for the FTE value then there is no guarantee as to which order they will come out in each time that the code is run. SQL Server is probably changing the query plan between when you do a simple SELECT and a SELECT with the WHERE criteria, causing a different order to come out and what you are seeing.

    I would add the PK onto the end of your ORDER BY just to ensure that the ordering is always consistent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very strange bug, which I believe is caused by some code
We have very strange problem, one of our applications is continually querying server by
I have a very strange behavior with Request.Form . Here are two IIS 7
I am developing an Android application with MapView and I have a very strange
I have a very strange bug going on. I cannot get the flyout to
I have encountered a very strange bug in Firefox. I have a javascript function
I have a very strange bug in a shipping iPad/iPhone app that I can't
I have isolated very strange bug from our current project: index.html (demo) and iframe.html
I'm experimenting with CUDA and I ran into a very strange bug. I have
I have very strange problem. I'm using IIS 7.0 Integrated mode for my application.

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.