Question

is there some way to tell sql server to use the (nolock) hint or every select in a stored procedure?

is pretty tiresome to add it to each an every select....

Was it helpful?

Solution 4

found this....

How to force nolock hint for sql server logins

seems like the best way to achieve this is to issue a

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

any other idea???

ps

another related question...

NOLOCK vs. Transaction Isolation Level

OTHER TIPS

As others quite rightly say, a global (nolock) is done using READ UNCOMMITTED.

However, before going down that route, it's worth trying READ COMMITTED SNAPSHOT first. This means your reads won't be locked by in progress inserts / updates and means that the data isn't dirty, just out of date.

I think this is what you are looking for...

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

You want to use the following syntax:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

I found this by looking at the NOLOCK table hint located here. The WITH(NOLOCK) table hint is equivalent to setting the isolation level to be READ UNCOMMITTED. Here's the snippet from MSDN:

NOLOCK Is equivalent to READUNCOMMITTED. For more information, see READUNCOMMITTED later in this topic.

However, you may end up with incorrect data. On 2005, it is preferable to use snapshot isolation: "When Snapshot Isolation Helps and When It Hurts" http://www.devx.com/dbzone/Article/32957

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top