LOCK TABLE PROBLEM

  • For SQL Server 2008:

    What is the procedure to delete some data from Lock Table?

    We can't use NOLOCK for Update, delete & Insert for that.

    A table Name like Business_History which is in Transaction Lock.

    Want to delete data where Proposal_Form_No='ABC'. If I Execute Select Operation With NOLOCK it shows 5 rows of data. But Can't delete them.

    Please Help.:(

  • pallab.santra1987 (1/24/2013)


    For SQL Server 2008:

    What is the procedure to delete some data from Lock Table?

    We can't use NOLOCK for Update, delete & Insert for that.

    A table Name like Business_History which is in Transaction Lock.

    Want to delete data where Proposal_Form_No='ABC'. If I Execute Select Operation With NOLOCK it shows 5 rows of data. But Can't delete them.

    Please Help.:(

    Seriously ?


    Sujeet Singh

  • Divine Flame

    Yes Seriously.

    I want a query(Delete) which works on nolock data of a lock table.

    If you have any idea .. please Help...

  • Okay, jokes apart. I think you want to delete the data from a table which is already locked as some other query is doing some modification in that table.

    If that is the case, you will not be able to delete the data from the table untill the first transaction is not complete. This is required to ensure data consistency & integrity as per the ACID property.

    If you are facing excessive locking then you need to look for the queries that are involved in locking & optimize them.

    Note: NOLOCK can't be used with DML operations such as INSERT, UPDATE & DELETE. Apart from that it should be avoided in SELECT statements too, as it actully enables dirty reads (you can read the data which is not-commited & even can be rolled back later by the transaction.)


    Sujeet Singh

  • check with sp_who2 , which spid is locking that table

    then for all fetched do dbcc inputbuffer(sp_id), see what kind of transaction is there

    then decide which spid you can kill (CAREFULLY) or wait for the transactions to get completed

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • Wait until whatever is using the rows has finished and the locks are released. If there's an orphaned transaction locking the rows, check with DBCC OpenTran and investigate whether or not to kill the session involved.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • THANKS @ALL... for your valuable reply...

Viewing 7 posts - 1 through 6 (of 6 total)

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