blocking and locking?

  • Hi All,

    Want to know the basic difference between blocking and locking?

    Thank You.

  • I think they cannot be compared.

    Locking is an action taken by SQL Server engine to protect data integrity. For example when a row is being UPDATEd it is locked by the database engine to make sure that other users can't DELETE/UPDATE it at the same time.

    Blocking is a situation where a process is waiting for another to release the lock.

  • While the are used synonymously there is the basic difference Suresh has just pointed out.

    Usually Locking is the cause of blocking. Ie. One process is locking certain rows with exclusive locks for example and this in turn ins blocking another process from performing any kind of operation on those rows.

    I guess your asking this as part of an interview question , so Sureshs answer would be good enough.

    Jayanth Kurup[/url]

  • LOCKING occurs when connection needs access to a piece of data in database and it’s necessary for SQL Server when managing multiple connections

    BLOCKING occurs when two connections need access to same piece of data concurrently and one connection is blocked because at a particular time, only one connection can have access

  • Thank you. πŸ™‚

Viewing 5 posts - 1 through 4 (of 4 total)

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