1

I've a query to run a SQL server table, in which, I am not concerned with the exact count. So, I want to specify NOLOCK for that query. But, query itself consists of multiple subqueries and multiple joins; so, it's quite dirty to put NOLOCK all around.

Although, I can set the transaction level "READ-UNCOMMITTED" for the tables, but that would change it for all other queries as well. I want to change the transaction level for that particular query, but without specifying NOLOCK in the query at multiple places. Is that possible?

5
  • 2
    "but that would change it for all other queries as well" - transaction isolation level is defined at the session level, it doesn't affect other sessions - and you can change your isolation level before and after this particular query. So I'm not clear on what "other queries" you're concerned about this affecting. Commented Mar 30, 2015 at 9:50
  • So, if I change before executing this statement. Will it not affect the other queries that are running on the same tables? Will they continue to run with the previous transaction level? Commented Mar 30, 2015 at 10:28
  • 2
    Yes, as I said, this is defined at the session level. Other sessions will use whatever isolation levels they have selected. Commented Mar 30, 2015 at 10:34
  • So, what would it take to make the transaction level change at a global level for a particular table? Commented Mar 30, 2015 at 10:54
  • I'm pretty sure this can't be set globally for a particular table. Commented Mar 30, 2015 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.