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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:34:44+00:00 2026-05-16T16:34:44+00:00

How do I select all rows for a table, their isn’t part of any

  • 0

How do I select all rows for a table, their isn’t part of any transaction that hasn’t committed yet?

Example:
Let’s say,

Table T has 10 rows.

User A is doing a transaction with some queries:

INSERT INTO T (...)
SELECT ...
FROM T

// doing other queries 

Now, here comes the tricky part:

What if User B, in the time between User A inserted the row and the transaction was committed, was updating a list in the system with a select on Table T.

I only want that the SELECT User B is using returned the 10 rows(all rows from the table, that can’t later be rolled back). How do I do this, if it’s even possible?

I have tried setting the isolationlevel on the transaction and adding “WITH(NOLOCK)” “WITH(READUNCOMMITTED)” to the query without any luck.

The query either return all 11 records or it’s waiting for the transaction to commit, and that’s not what I need.

Any tips is much appriciated, thanks.

  • 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-16T16:34:45+00:00Added an answer on May 16, 2026 at 4:34 pm

    You need to use (default) read committed isolation level and the READPAST hint to skip rows locked as they are not committed (rather than being blocked waiting for the locks to be released)

    This does rely on the INSERT taking out rowlocks though. If it takes out page locks you will be back to being blocked. Example follows

    Connection 1

    IF OBJECT_ID('test_readpast') IS NULL
    BEGIN
       CREATE TABLE test_readpast(i INT PRIMARY KEY CLUSTERED)
       INSERT INTO test_readpast VALUES (1)
    END
    
    BEGIN TRAN
          INSERT INTO test_readpast 
          WITH(ROWLOCK) 
          --WITH(PAGLOCK)
          VALUES (2)
       SELECT * FROM sys.dm_tran_locks WHERE request_session_id=@@SPID
       WAITFOR DELAY '00:01';
    ROLLBACK
    

    Connection 2

    SELECT i
    FROM test_readpast WITH (readpast)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to select all rows from one table which match one or more
I want to write a query to select from a table all rows with
I need a mysql query which will select all rows that contain joe in
If I fill the DataSet with DataAdapters that select all rows from Orders and
I need a MySql statement that will select all the rows, as well as
I would like to delete all the rows found by that query: SELECT cart_abandon.*
I have a table that lists people and all their contact info. I want
Here's what I want to accomplish: Select all rows from table posts while also
I am trying to query all rows of a parts table even if their
I'm trying to get all rows from my table by their id (the IDs

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.