views:

1306

answers:

5

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....

+3  A: 

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

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

J.13.L
+1  A: 

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.

Dan Wolchonok
A: 

found this....

http://stackoverflow.com/questions/64208/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...

http://stackoverflow.com/questions/1018651/nolock-vs-transaction-isolation-level

opensas
+5  A: 

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.

Robin Day
A: 

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

AlexKuznetsov