Who has what checked out?

It happens everywhere, I suppose. It's close to noon and we are all wondering if we oughtn't get some work done this morning, when somebody asks "Whatever happened to Jonesy?" To be honest for once, I hadn't noticed, and the few who had assume he hasn't returned yet from his annual vacation at Snakentick State Park. Nobody wants to wake the Boss, and the security guys just shift their eyes back and forth like Susanna Hoffs in a long loo queue, so finally someone else grabs the short straw and takes Cheryl from HR to a long lunch. He returns bleary-eyed, to report that Jonesy won't be needing his office chair anymore. I can't go into the details, but if you can explain how the video can be considered an allowable business expense, we'll give you your camera back.

A couple of weeks later, the Boss realized that Jonesy was gone and came to me, worried about some report that Jonesy had left checked out in SharePoint. "What are we going to do? We need that report today!" I told him it would take a lot of hard work, but I could fix it. Of course, all I did was log in as administrator and force the check in, followed by an afternoon of checking eBay listings for camera prices.

My reverie was interrupted when the Boss came back. "What if he left something else checked out? How will we ever know without looking at every single SharePoint page?" Startled at the stillness broken by a query aptly spoken (I didn't realize that he knew that SharePoint HAS pages), I knocked out the following SQL query. 

use CONTENTDB; 

Select d.DirName, d.LeafName, u.tp_Login

From dbo.AllDocs as d, dbo.UserInfo as u

Where d.CheckoutUserId = u.tp_ID

And tp_Login = 'DOMAINLOGIN'

It returns all documents currently checked out by the given user. Just replace CONTENTDB with your content database name, DOMAIN with your domain, and LOGIN with the user's login. You'll be sawing logs in no time.

Of course, we all practice Safe Sql, don't we? SELECT statements only in a SharePoint database, right? Right??

 

Leave a Reply