SharePoint 2007 - Unlocking Longterm Checked-Out Documents

In SharePoint there are two types of document checking-out:

Long term check out
This is the explicit check out . 
This holds a lock on the document whether you have it open for edit or not.

Short term check out
You get this feature implicitly. 
If you open a document for editing, you get a short term lock on the document to prevent other people from editing the doc while you are. 
The Office client applications refresh this lock periodically as long as you keep the document open.  Once you close the document, your short term check out is released.

At some point in time, you will run into the ‘DocumentName’ is locked for editing by ‘Username’ message when working with SharePoint or Project Server sites. Most of the time, this is a very valid message and is notifying the user that someone else is already editing the document.  But, sometimes we have experienced a user error, computer crashing, or a Database deadlock.  You can't delete the file and SharePoint Designer will not work either.

Here is how to fix it:

1. Use SQL Server Management Studio (or what you use to connect to your SharePoint database) to connect to your WSS_Content or Project Server content database

Run this query:

select * from alldocs where CheckoutUserId is not null

2. In the results, search the DirName column for site directory / file name path for the document that is locked. When you find the row, write down the user id from the CheckoutUserId column in that row

3. Run this update with the user id you wrote down and site directory / file name path:

update dbo.AllDocs
set CheckoutUserId = NULL, CheckoutDate =NUll, CheckoutExpires = NULL
where CheckoutUserId = <put user id here> and DirName = '<put site path/filename in here>'

Pay attention forming your query:

CheckoutUserId is an interger, so no single ' quotes around number
DirName is nvarchar, so needs single ' quotes around it
the brackets <> above in example queries are place holders - do not use in the queries

4. Refresh page on site and file is now unlocked.

Permalink | Comments (0) | Post RSSRSS comment feed