Solved

SQL Server 2005 record lock

Posted on 2011-03-24
6
435 Views
Last Modified: 2012-08-14
I am currently have a locked record in a table called IV00101. There is some kind of lock on one record in this table. There is a part called 255A4330P001. I cannot even do a select statement against this part. If I try, the command just sits there running and the query never completes. Is there a sp I can run that will show me the lock currently on this record?
0
Comment
Question by:rwheeler23
  • 3
  • 2
6 Comments
 
LVL 39

Expert Comment

by:lcohan
ID: 35210343
you can try sp_lock and check for all locks on the objectid for your table
0
 
LVL 39

Assisted Solution

by:lcohan
lcohan earned 500 total points
ID: 35210396
You can replace the table_name in query below and try it on your server to find all lock for that object:

create table #locked_objects (spid int,dbid int,objid int,indid int,type sysname, resource sysname,mode sysname,status sysname)
insert into #locked_objects exec sp_lock
select * from #locked_objects where objid = object_id('table_name')


0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35210481
fyi:
select * from IV00101(nolock) where part= '255A4330P001' 

Open in new window

should work whatever lock is on the table/row ...
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:rwheeler23
ID: 35210714
OK, I have the SPID but how do I know which one is the lock? I see about a dozen records on this table. Do any of the columns tells me where the lock is?
0
 

Author Comment

by:rwheeler23
ID: 35215096
Rebooting the server was the only way to free up the lock. There were about 3 possible candidates. Restarting the SQL service would have accomplished the same thing.
0
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 35217955
Next time you should try KILL SPID number instead of restarting the server and you can also use Activity Monitor (or SP_WHO2) to get more info about the process that's locking that badly to take action in the future.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now