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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:25:18+00:00 2026-05-23T07:25:18+00:00

Since I can’t post an answer to my previous question yet, I decided to

  • 0

Since I can’t post an answer to my previous question yet, I decided to open a new post. To make things work with the code in that post, I had to add the hints WITH ( ... , INDEX ( IX_REQUESTID ) ) and WITH ( ... , INDEX ( IX_REQUESTIDREF ) ) to the tables Request and Options respectively. It seems that SQL Server was unable to find which index to use itself, because now it does the job correctly. But now the problem is other… I appended to the statement the clause ORDER BY Priority, DateEnteredand even though there is an index on (Priority, DateEntered) INCLUDE (RequestID) on the RequestTable, Query2 returns no results again… What can be wrong this time? Please help me, since this is really important and I can’t figure out an answer myself.

  • 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-23T07:25:18+00:00Added an answer on May 23, 2026 at 7:25 am

    There may be further requirements I’m not aware of, but when my code gets to a certain level of complexity I usually stand back and ask myself – could I do things simpler.

    In this case, could you not run the query on just the Request table and store the values returned into a tablevar?

    You’ll probably need to set Transaction Isolation Level Serializable in order to get the row locking you desire. Not sure though – would need to try with and without.

     SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
    
     DECLARE @TempResults TABLE (RequestID int, Priority int, DateEntered DateTime)
    
     INSERT INTO @TempResults (RequestId, Priority, DateEntered)
     SELECT TOP 2 RequestId, Priority, DateEntered FROM Request WITH (ROWLOCK, UPDLOCK, READPAST) 
     ORDER BY Priority, DateEntered
    

    Now with the rows locked join between the tablevar and the Options table to return the result-set you require.

     SELECT * FROM @TempResults Request INNER JOIN Options ON Request.RequestID = Options.RequestIDRef
    

    I apologise if this isn’t an option for you.

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

Sidebar

Related Questions

Since I can't make any comments (only post an answer) to this post ,
since I can't get CEDET to work for automatic code-completion (aka intelli-sense in the
edit 10/8/10 @ 8:20am est - since I can't make this work in prod,
The following code gives a NullReferenceException since XPathSelectElement can't navigate through the XPath expression
Since you can't apply custom headers on JSONP calls , how do I make
This is a really basic regex question but since I can't seem to figure
I've just started using Eclipse for Python development since we can make use of
I'm fairly sure this is a template question, since I can't seem to solve
I have realized that my first question won't be answerable, since php can't deal
So since i can't make a peace with myself as i really want to

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.