Recent Articles:


I’ve seen this mistake more than once, from DBAs with a middling to fair amount of experience. So it bears repeating. RECOVERY_PENDING is very different from RECOVERING.


RECOVERING means that things are happening, and all may be well. “Database is being recovered. The recovering process is a transient state; the database will automatically become online if the recovery succeeds. If the recovery fails, the database will become suspect. The database is unavailable.”

RECOVERY_PENDING means that something is wrong, and YOU have to fix it. “SQL Server has encountered a resource-related error during recovery. The database is not damaged, but files may be missing or system resource limitations may be preventing it from starting. The database is unavailable. Additional action by the user is required to resolve the error and let the recovery process be completed.”

(Definitions from the Technet article “Database States“.)

Finding the database state

Finding the state of your databases is easy. You can look in Object Explorer, and it’ll say so right there:

You can look in sys.databases, which is the preferred method:

SELECT name, state_desc
FROM sys.databases;
– Optional: WHERE state_desc <> ‘ONLINE’;

(Why is that preferred? Because it’s programmatic, and so repeatable and fast and usable in automated scenarios. And ot’s more accurate, as the GUI can glitch or cache information, whereas sys.databases never never does. )

And of course, you can look in the SQL Server error log and see if any errors popped up while recovering databases (for example, during SQL Server startup, or when the database was set online).

When good databases go RECOVERY_PENDING


One of the more common scenarios for RECOVERY_PENDING is that a database file is missing, or renamed, or moved, or who knows what. That’s definitely the place to start. After all, the error log – remember the error log? – will often tell you that this it the problem. Look here:

FCB::Open failed: Could not open file C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\Demo.mdf for file number 1.  OS error: 2(The system cannot find the file specified.).

In this case, it’s very clear; it can’t find the file. As it turns out, that’s because someone renamed the file while the database was offline (either while SQL was stopped, or the DB was in an OFFLINE state). So I renamed the file properly, set the database to ONLINE, and all was well.

You’ll occasionally get RECOVERY_PENDING after a service restart, for no good reason, and I don’t know why. SQL Server gives you error 17204, “Open failed: Could not open file …. OS error: 32(The process cannot access the file because it is being used by another process.)” And then error 5120, which carries the same message.  This is nearly always resolvable by setting that particular database offline and online again.

Stop. Rebooting. The server. Durnit.

Note that I do not recommend rebooting the server, or even restarting SQL. It’s a problem with a single database. I’d very much like this message to get out there: Most problems in SQL are solvable without a restart!  Especially THIS problem.

Happy days,
Jen McCown

SQL Sins and Powershell scripts, from another lovely #SQLSatOKC

August 25, 2014 sql server 2 Comments

Hi-ho there, Jen the DBA here. We spent a lovely weekend in balmy (99F and 30% humidity) Moore, Oklahoma for SQL Saturday #309.

On Friday, Sean and I gave our “Become an Enterprise DBA” precon, and had dinner with the natives. Thanks again, OKC UG, for the dinner and beer! Friday night we had our regular DBAs@Midnight, titled “3 Rants”, where we talked about the new Coke* campaign, and the darn SQL whippersnappers these days, and that companies and orgs really need to STOP REBRANDING CONSTANTLY BECAUSE THAT’S A REALLY BAD IDEA. I’m looking at you, “SQLPASS-not-SQL Server“.



Saturday, we attended our very first T-SQL Throwdown, hosted as always by its creator, Hakim Ali. I had been recruited as an “Expert for Hire”, though no one wound up “hiring” me…and this was so much fun! Hakim tells the attendees to form groups of 2-4, with at least one laptop (with SQL installed) among them. Some people choose not to participate, but that’s fine, as it turns out that coding actually IS a good spectator sport.

He passed out USB sticks with the password-protected questions, and began. He revealed the password for the first question, and the teams got right to work. As a team figured out the answer, they’d come up to the front to type it in on the display. If they got it wrong, the next team in line – if there was a team in line at all – could try. The points, and the difficulty, ramped up question by question.

It was great. Some teams would get most of the way there, and fail on a typo. Others would get the answer NEARLY right, but leave out one crucial detail. Nobody was requesting expert help (it costs half the question’s points for an expert), so he made the experts free for teams that hadn’t scored yet.

After 10 questions, the winning team just barely took the lead, and took home the prizes. I was really pleased with how entertaining and engaging the whole event was. (I’m going to push him for a Celebrity Throwdown sometime…)

okcposhOur Sessions

Sean presented his RegEx for DBAs session (here’s the code) to fill in for a last minute cancellation, and then presented DIY Performance Reporting (demo code) as the last session of the day.

I presented both Code sins, and my new Powershell Cmdlets for DBAs session (download the code file here), which seemed well received.

Thanks very much, OKC, for a fantastic SQL Saturday!

Happy days,
Jen McCown


*I don’t mean New Coke. That’s just not okay.

The Big Idea is: Nobody likes team building

In our Season 6 opener of DBAs@Midnight, we talked about (among other things) the giant pain that is company-mandated team building.  I’m writing here from my experiences as an IT professional, with many years of work, and many hours wasted in “building teams”.

Team building assumes that you are part of a working team – fair enough so far – and that non-work activities can help strengthen and improve the relationships within those teams, with the end goal of better productivity for the company. It really does seem like a fine idea, as far as that goes, and I applaud managers and brass for realizing that workers are more than cogs in a machine.

The thing is, a great many people hate-hate-HATE team building.

I’ve been to team building events that included silly games, dancing, picnics or bowling, pointless (and endless) motivational speeches COMPLETE WITH LOTS AND LOTS OF POWERPOINT, and on and on. The active stuff was generally embarrassing. The picnics and bowling were nice I suppose, but afterward measured little to no impact on working conditions; it was effectively a company party. The speeches were…not good for anyone’s enjoyment of life, to say nothing of productivity. Never has so much minesweeper been played by so many people, in such a small, sweaty room.

One of the big problems is that team building is rarely done for teams – it’s done across departments, and so you have groups of people mixed up together, doing things that at least half of them despise.  It’s hard to plan even a party for a large group of people, much less a goal-focused set of activities. Too many personality types. The introverts won’t want to sing, the extroverts will get bossy about the logic puzzles, the lazy ones will spend all their time on Plants vs Zombies 7, The Reaping, and now you’re not so much team building as you are shoring up existing roles.

And the really great thing is, it’s always mandatory. You never get asked whether you’d like to participate in team building, or what might interest you, or how you think these things might be run well.  In short, team building tends to be a funnel that transforms perfectly useful time into long, awkward uselessness.

I’d like to hear from people who’ve had good team building experiences. I’d like to hear from those of you with bad. And, can team building be done “right”?

Happy days,
Jen McCown


Tune in to DBAs@Midnight, the only live webshow for DBAs, by DBAs, Fridays at 11pm Central on for the next Big Idea. When you watch and chat live, you’re part of the discussion! (Show is NSFW for language.)

MidnightSQL Consulting

Need help? Got an emergency? Write us at!

We can schedule time to help with your backup/restore issues, high availability and disaster recovery setup, performance problems, and a great deal more. Very often, we're even available on the moment for downtime issues and emergencies.

For more information about MidnightSQL consulting, email us or check out Happy days!

Where are We?

September 13: SQL Saturday Kansas City
November 3-7: PASS Summit, Seattle, WADecember 11: Presenting "Powershell Cmdlets.." at Alaska SQL Server User Group

Blog Posts by Category


How to Eat Pop-tarts
Watch DBAs@Midnight live on Fridays,m 11pm Central time

The best database career advice you’ve never heard!

The DBA Roadmap Seminar is 7 MP3 tracks (over 5 hours!) of insider guidance on your database career. We'll teach you how and what to study as a DBA, weigh in on controversial resume debates, teach you to recognize a worthy recruiter, and discuss the new professionalism of interviews. Also some bonus materials, PDF companion guides, and really spiffy intro music!

Once your $99 PayPal payment is submitted, you'll get the download link in e-mail! (Download is a 370Mb ZIP file.)

Become a DBA. Become a BETTER DBA. Use the Roadmap.

Visit for info, forums, and more!

Add to Cart View Cart

Cunningham’s Law

"The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer."