Follow Savance Enterprise on FacebookFollow Savance Enterprise on LinkedinFollow Savance Enterprise on Twitter
Take Your Business to New Heights with Savance Enterprise

Savance Enterprise Support

Main

Knowledgebase: Administration
Fix a Locked Database
Posted by Jacob Fairbairn on 27 May 2014 03:45 PM

First of all, check to see if the database is locked by running the following:

sp_lock

 

This lets you know what is currently locked right now because something is currently calling it to update it. If there are only a couple hundred rows, that is alright. However, if there are several thousand, then there is a problem. To find more information overall, please view this knowledgebase article:

Find Details on a SQL Process

 

For more information overall, try running the following (this may take a very long time if the database is badly locked):

sp_lock2

 

Now if you would like to find the locked process, run the following:

sp_who

 

The blk column indicates what is blocking the process in the given row. If this value is zero, that means nothing is blocking it. If it is non-zero, then this column will show the spid value of whatever is blocking this process. Now go to that process and see what's blocking it. Continue to do this until you find the source (the source will not be blocked).

 

If you would like more details on a process, you can run this command, which displays the last statement sent from the client to the SQL Server:

DBCC INPUTBUFFER ([spid])

 

If you would like to manually end a process from the database, you can run this command:

kill [spid]

 

You can also view ALL locked processes, if necessary, with this command: 

SELECT * FROM SysProcesses WHERE Blocked = 1

 

If all else fails, you can restart the SQL Server service from the Windows Services.


Savance | The Company

At Savance, we set ourselves apart from our competition by keeping it personal. We actively request feedback, know our customers by first name, integrate their ideas into our product, and measure our success based on their happiness. The way businesses used to be run.

NAED American Lighting Association IMARK Plumbing STAFDA HARDI Blue Hawk HVACR Cooperative

Contact Us