With (nolock), (nolock), nolock differences?

I know that with(nolock)they (nolock)are the same or almost the same. REF: with (nolock) or (nolock) - Is there a difference?

but what about nolock? You can use any of these in select, and the only noticeable difference that I see is to use an alias that you can write:

select * from table1 as mytable with(nolock)

or

select * from table1 as mytable (nolock)

but you cannot write:

select * from table1 as mytable nolock

PS : I do not discuss nolockgood or bad here :)

+4
source share
2 answers

The difference is that you must use the syntax WITH (NOLOCK)(or WITH (<any table hint>)). Why?

  • WITH . MSDN:

    WITH : Microsoft SQL Server. , .

  • from table1 nolock - . :

    SELECT nolock.name FROM sys.objects nolock ORDER BY nolock.name;
    

    , nolock . .

  • from table1 as mytable nolock SQL Server.

    Msg 1018, 15, 1, 12
    "nolock". , A WITH . . SQL Server Books Online .

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, , 15 WITH (NOLOCK), . (, RCSI, , READ UNCOMMITTED IMHO), - .

, , OP, , nolock, , :

+10
+1

All Articles