Update with NoLock

  • What will be working difference between the 2 Queries in  SQL Server.

    Type #1

    update  a

    set  a.authstatus   = 'VALID'

    from author a(nolock)

    where a.author_name   = @name

    and  a.dob   = @dateofbirth

    Type #2

    update  author

    set  authstatus   = 'VALID'

    from author

    where author_name   = @name

    and   dob   = @dateofbirth

    Can we use NoLock in the Update Statement. What is the significance for the use?

     

  • Since this is an update there essentially no difference because the update will still need to acquire an exclusive lock in order to perform the update. Thus, if another transaction has locks on this table the update may have to wait for it to complete (unlike a select statement with nolock).

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply