SQL Server Recovery – Secondary Data File in ‘Recovery Pending’ State but Database is Online

recoverysql server

I got an issue. I have a database (Say, DBASE) which have three files – Two data files (namely D:\Data1.mdf and D:\Data2.ndf) and a log file (E:\log.ldf) and all are in different file group. The secondary data file i.e., Data2.ndf is in recovery pending state. Remaining two db files are good and my database is online. When I took a look on database properties (GUI), I found there the size of Data2.ndf as 0MB where it's actual size is 10GB. We have given a try in below methods to fix the issue, but no luck.

  1. resetdbstatus
  2. Taking database to offline, then back to online.
  3. Detach and attach operations
  4. No errors from checkdb, unfortunately we don't anything in error log (as they are recycled)

Can someone help me in fixing the issue please?

FYI – Version : SQL 2012 SP1 Enterprise.

Best Answer

Since you mentioned earlier that your DB gets restored daily and it has different filegroups, it seems to me the case of piecemeal restore. You need to check the script used for restore and make sure it is recovering all the filegroups present in the DB backup.

It looks like currently the script is only recovering primary filegroup and skipping the others which is causing the DB to recover but without the skipped filegroups. So you can query all your data which is present in PRIMARY filegroup but not the skipped ones. Just recover all the filegroups using the example given in below link and you should be fine.

http://blogs.lessthandot.com/index.php/datamgmt/dbadmin/sql-server-filegroup-piecemeal-restores-1/