SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


LOCK TABLE PROBLEM


LOCK TABLE PROBLEM

Author
Message
pallab.santra1987
pallab.santra1987
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 5
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.Sad
Divine Flame
Divine Flame
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2363 Visits: 2816
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.Sad


Seriously ?


Sujeet Singh
pallab.santra1987
pallab.santra1987
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 5
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...
Divine Flame
Divine Flame
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2363 Visits: 2816
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
Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5520 Visits: 4076
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;-)
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91537 Visits: 45285
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


pallab.santra1987
pallab.santra1987
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 5
THANKS @ALL... for your valuable reply...
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search