Wednesday, March 7, 2012

NOLOCK statement

If you were to set up a SQL statement with 6 tables and you want to make
sure all 6 tables were not locking other tables should a NOLOCK statement be
placed after each table name?
Thanks,
select a.table_name, b.table_name, c.table_name,
d.table_name, e.table_name, f.table_name
from a (NOLOCK),
b (NOLOCK),
c (NOLOCK),
d (NOLOCK),
e (NOLOCK),
f (NOLOCK)Or you could use SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
http://www.aspfaq.com/
(Reverse address to reply.)
"Joe K." <JoeK@.discussions.microsoft.com> wrote in message
news:3FD67600-052E-4E91-8EF1-D5A7E22B1346@.microsoft.com...
> If you were to set up a SQL statement with 6 tables and you want to make
> sure all 6 tables were not locking other tables should a NOLOCK statement
be
> placed after each table name?
> Thanks,
> select a.table_name, b.table_name, c.table_name,
> d.table_name, e.table_name, f.table_name
> from a (NOLOCK),
> b (NOLOCK),
> c (NOLOCK),
> d (NOLOCK),
> e (NOLOCK),
> f (NOLOCK)
>|||As Aaron stated it may be easier to use the READ UNCOMMITTED isolation level
but you should get in the habit of using WITH when you specify hints.
While it is optional now it may not be in the next release.
Andrew J. Kelly SQL MVP
"Joe K." <JoeK@.discussions.microsoft.com> wrote in message
news:3FD67600-052E-4E91-8EF1-D5A7E22B1346@.microsoft.com...
> If you were to set up a SQL statement with 6 tables and you want to make
> sure all 6 tables were not locking other tables should a NOLOCK statement
> be
> placed after each table name?
> Thanks,
> select a.table_name, b.table_name, c.table_name,
> d.table_name, e.table_name, f.table_name
> from a (NOLOCK),
> b (NOLOCK),
> c (NOLOCK),
> d (NOLOCK),
> e (NOLOCK),
> f (NOLOCK)
>

No comments:

Post a Comment