SQL 2012 database stuck in Recovery Pending status

Hey all.  Thanks in advance to anybody that can please help me.  I have a SQL cluster which ran out of disk the other day.  I threw plenty more disk at the SAN.  However, 1 of the databases came back with Recovery Pending and has been
over 24 hours.  I have tried to backup the database with no success.  I don't have a clean backup from the day it occured so would have a good amount of work missing.
Running a dbcc check returns the following:
Msg 945, Level 14, State 2, Line 1
Database 'sqldb' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.
I have not tried a dbcc check with REPAIR_ALLOW_DATA_LOSS as there seems to be a high risk of losing whatever was going on.  Does anybody have an idea of how I can get the db back online?

Just a note... the database is not in Suspect mode, it is in Recovery mode.  If there is a transaction in process, attaching and reattaching may or may not trigger the transaction to complete.    The answer would be different if the database
were in suspect mode.  The fact that it is now in CHECKPOINT shows that there is an incomplete transaction.  Once back online, a backup can occur and the CHECKPOINT can resolve.
http://support.microsoft.com/kb/110139?wa=wsignin1.0
Seems to me this is more like a case where the database is in log ship mode.  In that case, the solution is relatively simple (this is not what needs to happen... it simulates what has happened):
RESTORE DATABASE MyDB WITH RECOVERY
USE master
ALTER DATABASE MyDB SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER DATABASE MyDB SET ONLINE
RESTORE DATABASE MyDB WITH RECOVERY
I don't believe you want to rollback anything though.  As you state above, the big trick is to bring it online.
I think you can get it into Single User Mode and then from there, restore the diffs and the logs after backing up the tail, then restore the tail and put it back into multi-user mode.  Given the difference in opinion here, I am feeling a little gunshy.
RESTORE DATABASE [MyDB]
FROM DISK = 'c:\MyDB.BAK'
WITH MOVE 'MyDB_Data' TO 'c:\data\MyDB.mdf',
MOVE 'MyDB_Log' TO 'c:\data\MyDB_log.ldf' 
R, J

Similar Messages

  • Database in 2012 Express with SP1 frequently goes to "Recovery Pending" Status

    We have installed 2012 Express with SP1 on Windows Server 2008 SP2 Standard (on Virtual machine).
    The database is with the capacity of around 200 Megs only but frequently the database is going to "Recovery Pending" status.
    There was no server or instance restart.
    Simply by running the following command, we are able to bring back the db to online
    ALTER DATABASE MYDB SET ONLINE
    There is no notable message recorded in SQL Errorlog.
    Any clue or idea what could be the cause of this frequent Recovery Pending status for a particular database ?
    Note: We have executed the DBCC CHECKDB on this database and the db is intact.
    Thanks in advance.

    Hello,
    "Recovery Pending" state indicate that Database has encountered a resource-related error during recovery. the most common one is the log file is missing or corrupt. If the error occurs due to log file corruption, Please try to switch the database to emergency
    mode, then to single user mode, run DBCC CHECKDB with the repair_allow_data_loss option to repair the database.
    Please see this similar thread:
    http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/835dee9b-0993-433f-baf7-a646dfa7f8f7.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click 
    here.
    Fanny Liu
    TechNet Community Support

  • Database msdb cannot be opened due to inaccessible files or insufficient memory or disk space - in recovery pending status

    came in this fine monday morning and it looks like developers were running some kind of trace that filled the primary DATA folder with about 80,000 5mb trace files.  now that process has stopped and the logfiles have been cleaned up, but when attempting to connect to the server using the management console i get the error:
    Database 'msdb' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details. (.Net SqlClient Data Provider)
    when i check the status it is in recovery pending mode.  i have a backup from yesterday but im not sure if this database became corrupt before that backup or not because this process was ongoing over the weekend.  the last timestamp on the msdb and log files is 7am this morning.. 
    I am not sure how to proceed recovering the msdb database with limiting interruption to the users.  any advice is extremely appreciated.  this is sql server 2008.  i can login via sqlcmd and see it is in recovery pending status:
    1> select state_desc databasestatus_sysdtabase from
    2> sys.databases where name ='msdb'
    3> go
    select state_desc databasestatus_sysdtabase from
    sys.databases where name ='msdb'
    databasestatus_sysdtabase
    RECOVERY_PENDING
    (1 rows affected)
    1>

    For someone experiencing a similar problem this answer is unacceptable. You're basically telling me to reboot the server to fix this.  You vaguely mention using process explorer to find out who is using the file.  Can you please provide
    some more information on that?  I have a similar problem and rebooting the server to fix it is not an option.  This problem keeps reoccurring.
    OS Error 32 means file has an open handle by someone else. If that is a user process then you can catch it via Process Explorer. If it's a kernel mode object then it's difficult to catch that and restart is the only choice.
    http://sqlserver-help.com/2014/08/07/tips-and-tricks-os-error-32the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Use a SQL 2012 database server with Reporting Services 2008?

    Hello, we have a SQL Server 2008 R2 Reporting Services Standard server with the reporting databases running on a SQL Server 2008 Standard database server. I would like to upgrade the database server to SQL Server 2012 before I upgrade the reporting server.
    Can I run SQL Server 2008 R2 Reporting Services against a 2008-version database running on a SQL 2012 database server? Thanks for your help.

     
    Hi Nicole
    Thanks for your posting.
    Are you asking if we can connect from SSRS 2008 r2 to a database sitting on SQL Server 2012.  Am I right?, please ignore me if I misunderstood your question. If that is your question
    then I think you will be able to using BIDS 2008, I have created A database on SQL Server 2012 and I use that database table inside  my SSRS 2008 R2 dataset. I can even think that you can use a database of compatibility level of 2012(110) as well
    Many thanks
    Syed Qazafi Anjum

  • SQL 2012 Management Studio Remote Servers Service Status Slow/Stops Working

    This is a huge annoyance.  I manage about 50 SQL instances of SQL Server versions 2005-2012 and I noticed that it takes 1-2 seconds to load the service status (green arrow) on each individual server.  If you then connect to a server, you have to
    wait for all the statuses to be loaded first in the Registered Servers list before it loads the statuses for servers in the Object Explorer.  This happens whether the servers are registered in Local Server Groups or Central Management Servers, and whether
    I have access to all servers (as windows local administrator and sa), or not.  It also happens regardless of whether I run as Administrator or normally on my instance of SSMS (which is SQL 2012 Development on Windows Server 2008 R2).
    These servers are also registered in alphabetical order by group and server name, which means that if I have "DEV" groups, they will be registered before "PROD", unless I rename accordingly.  It sometimes takes a few minutes, if
    I'm lucky, to get a server I connect to to load, which means I can't use SSMS to really manage any remote servers and start/stop/pause/resume/restart services.
    Worse, sometimes due to a server becoming unavailable (due to updates/patches/failovers), SSMS is unable to load the service statuses anymore for any new server connections made to object explorer, resulting in the loss of ability to view/change service statuses. 
    In this case, there is no way to recover (Refresh of Central Management Servers does nothing), except to close SSMS and open it again, and then wait again for all the statuses to load.
    I have lived with this since first installing SQL, and regardless of the Windows Updates and SQL patches applied, the problem has never gone away.  This also happens if I load SSMS in Windows Server 2012.  Its starting to become a huge issue now
    that I have to patch several servers each month.
    I have already checked WMI permissions, GPO, firewall, etc. as per all the suggestion on the internet, including this post
    http://www.sqlservercentral.com/Forums/Topic825246-146-1.aspx.  None of these suggestions have made a difference, as my real problem is one of connectivity and performance, and
    not security, which most of these suggestions apply to.  Of note, all servers are in the same domain, firewall is disabled across the board, correct permissions for local administrators exist for remote registry settings, WMI, GPO, etc, and all service
    accounts and windows accounts that are used are local admins and sysadmins.
    My work-around has been to delete the Central Management Server and any local server group registered servers, close and re-launch SSMS, and then connect to a server I'm interested in via Object Explorer.  Otherwise, close and re-launch will take forever. 
    My other alternative is to RDP into the remote server and manage services via SQL Configuration Manager locally.
    If anyone has any ideas on how to fix this, or make it go faster, I'd really appreciate it.
    Diane

    Hi Satish,
    Thanks for taking the time to reply.  Yes, I actually am already using work-arounds (i.e. methods other than SSMS) to accomplish my tasks.  My issue is that this is supposed to be working and provide a nice GUI so that you can easily visualize
    any issues, and address them directly, without having to hodge-podge access via scripts or 3rd-Party tools.
    Since no one else has any comments, I guess there are no plans to make remote server administration work with SSMS properly then, and that kludge methods are the only ones being advocated.
    Diane

  • SQL 2012 Database Availability Group - Force Automatic Failover

    Hi All,
    I'd appreciate some help in understanding the following scenario in my test environment.
    I have created a DAG with 2 replica servers (both of which are HyperV VM's running W2012 Std).
    From a client PC in my test lab, I can connect to the virtual listener of my DAG and confirm via the "select @@servername" command that I am connecting to the primary replica server.
    Using the Failover Wizard, I can easily move to primary instance between my 2 nodes and the command above confirms that the primary replica server has changed. So far so good.
    What I wanted to test, was what would happen to my DAG in the event of a complete loss of power to the server that was acting as the primary replica server. At first, I thought I would stop the SQL Server service on the primary server, but this did not result
    in my DAG failing over to the secondary replica. I have found out that the only way I can do this is by effectively shutting down the primary server in a controlled manner.
    Is there any reason why either stopping the SQL Server service on the primary replica, or indeed forcing a power off of the primary replica does not result in the DAG failing over to the secondary replica?
    Thanks,
    Bob

    Hi,
    I would verify if Database Availability Group means AlwaysOn Availability Group.
    How did you set the FailureConditionLevel?
    Whether the diagnostic data and health information returned by sp_server_diagnostics warrants an automatic failover depends on the failure-condition level of the availability group. The failure-condition level specifies what failure conditions
    trigger an automatic failover. There are five failure-condition levels, which range from the least restrictive (level one) to the most restrictive (level five). For details about failure-conditions level, see:
    http://msdn.microsoft.com/en-us/library/hh710061.aspx#FClevel
    There are two useful articles may be helpful:
    SQL 2012 AlwaysOn Availability groups Automatic Failover doesn’t occur or does it – A look at the logs
    http://blogs.msdn.com/b/sql_pfe_blog/archive/2013/04/08/sql-2012-alwayson-availability-groups-automatic-failover-doesn-t-occur-or-does-it-a-look-at-the-logs.aspx
    SQL Server 2012 AlwaysOn – Part 7 – Details behind an AlwaysOn Availability Group
    http://blogs.msdn.com/b/saponsqlserver/archive/2012/04/24/sql-server-2012-alwayson-part-7-details-behind-an-alwayson-availability-group.aspx
    Thanks.
    Tracy Cai
    TechNet Community Support
    Hi,
    Thanks for the reply.
    It's an AlwaysOn Availability Group.
    In my test lab, I have changed the quorum configuration to a file share witness and that has allowed an automatic failover when I turn the primary replica server off (rather than power it off).
    I'll take a look at the links you provided.
    Regards,
    Bob

  • SQL 2012 database behaves differently with a unique index and ignore_dup_key = on when inserting data. It works on SQL 2008 db

    If you have a table with a unique index and ignore_dup_key = on and you INSERT rows into that table with an ORDER BY clause (because you want to control which of the duplicate
    key rows gets inserted),  the wrong row gets inserted in SQL2012.  It works correctly in SQL 2008.
    We have recently migrated  a database from SQL 2008 to SQL 2012.  We do have few other dbs which are in compatability mode 100.  The above operation works fine
    in SQL 2008 dbs but not SQL 2012.
    I've even tried applying the latest patch for SQL 2012 SP2 with CU2. Still the problem exists.  I'm going to call MS support, but want to know if anyone has come across this problem ?

    The MS documentation doesn't guarantee that the first row of the duplicates will always be inserted and the next duplicate row(s) get(s) ignored. Where did you find it in the MS documentation? I think you were just lucky that it was always inserting the
    first row in SQL 2008 (and ignoring the rest of the duplicates) - I don't think this is guaranteed
    Satish Kartan http://www.sqlfood.com/

  • Backup and Restore of DQS (Data Quality Service SQL 2012) Databases

    We are currently using DPM 2010 running on Server 2008 R2 as our backup solution.  We will soon be leveraging the Data Quality Services in SQL 2012 along with the Master Data Service.  
    In the SQL 2012 documentation from Microsoft it states, “The backup and restore operations of the DQS databases must be synchronized.” 
    Otherwise the restored Data Quality Server will not be functional.  Currently I believe that DPM will run serialized backups of databases from one SQL server. 
    I was hoping someone could point me towards some documentation for backing up DQS with DPM. 
    Is anybody currently doing this?  If so have you been successful restoring?

    LogicalName cant be same for mdf and ldf. verify again with FILELISTONLY. Also you have put wrong logical name 
    MOVE N'OriginalDB' TO N'D:\sql data\TargetDB.mdf'
    Please paste the output of
    RESTORE FILELISTONLY FROM DISK = 'D:\backup.bak'

  • Secure login to sql 2012 database for webusers

    We build up a new website in .net mvc 4.0 on a w2012 server with MSSQL 2012 database.
    We use windows autentification and normal anonymous access through NT AUTHORITY\IUSR who is also a login in the database.
    But we make extra login possibility for users who are registered and they can insert and modify data in some tables in the database. And I'am afraid of giving NT AUTHORITY\IUSR insert and update for some column in tables.
    I think of set up a new login for the database. Run a new connection string on login and set up special permission for that extra user on the database, set up a new role and let the new user become member, but also let the user become a member of the ordinary
    user(roles) in the database.
    Have anyone any idea what is the best practice here and the most secure way to do it? 
    Any links for other resources about this topic?
    Or perhaps my fear for using NT AUTHORITY\IUSR is groundless
    And perhaps someone has links to resources for using SQL server as a backendserver for websites. 
    Knut from Norway!

    I don't know much about web servers, which may explain your alternatives entirely.
    But, if you use the same connection string for reads that you do for updates, then you must control all permission for writes in the web app. And you must be sure that you only use parameterised SQL or stored procedures, so that there is no risk for SQL
    injection.
    If you give special logins for the users with read access, they would need their own accounts in SQL Server. If this is an intranet site, the web server may be able to impersonate these users and then connect to SQL Server. If that does not work out, you
    would have to create SQL logins for these.
    Obviously, this requires more administration, but it is also more secure, because you are adding a line of defence. Even if your application is free from SQL injection vulnerabilities today, some new badly educated kid on the block could open a hole two
    years later.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SQL 2012 Database Mirroring Issue is stalling

    hi All, 
    I have a SQL 2012 Enterprise Primary and DR SQL Clusters. 
    I have a 500 GB TDE Enabled Using HSM SQL DB which I have mirrored across to DR. 
    I am noticing that my Logs are shipping to DR, but the Unrestored Log size is huge and My restore rate is about 0 - 80KB/Sec. This is Causing the unrestored
    Log to grow on the DR side. 
    I also notice at times my Unsent Log is also getting big after any DB Maintenance activities (such as rebuild of indexes). 
    I have a dedicated connection between my datacenters and the traffic thruput is quite reasonable and I am able to copy out a 2GB File across within a few
    minutes. I see no packet drops within my links. 
    How do I ensure that my unsent logs are copied out and also increase my restore rate in DR side. 
    Any help / Suggestions will be much appreciated.   
    Regards 
    Aravin. 

    You need to limit the amount of reindexing you do on your primary/principal as it generates a lot of logs which slows down mirroring and log shipping.
    looking for a book on SQL Server 2008 Administration?
    http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X looking for a book on SQL Server 2008 Full-Text Search?
    http://www.amazon.com/Pro-Full-Text-Search-Server-2008/dp/1430215941

  • SQL 2012 database master key

    Hi All ,
    I have some issue to create database master key in SQL server 2012.
    I have typed this command below:
    USE master 
    CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'passwordbypolicy'
    This is the error I got:
    Msg 33094, Level 16, State 1, Line 2
    An error occurred during Service Master Key decryption
    Can somebody help.
    Thanks ,

    Below is the link for it:
    http://msdn.microsoft.com/en-us/library/ms174382.aspx
    Please be careful on your password part as there are some norm attached to it.
    Also if it is giving you any more issues better clean your instance and try again. In some cases it doesn't  work as we might forget something to remove completely.
    Santosh Singh

  • Update sql 2012 database from access 2003

    Hi, all,
    I have a new sql server 2012 and has already created a database same as the one from access 2003. 
    Can someone give me a details or links how to update sql server 2012 through SSIS package? I know I could use import wizard but it is a customized version of SSIS. And I want to build my own project using SSIS package.
    source: access 2003 on old sql server 2005
    destination: sql server 2012.
    Thanks.

    you can try this
    http://www.mssqltips.com/sqlservertip/2484/import-data-from-microsoft-access-to-sql-server/
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to convert sql 2012 database to 2008

    i have 2012 sql database file (.mdf ans .ldf ) how to connect same database in 2008 sql server . please help me its very urgent 

    i have 2012 sql database file (.mdf ans .ldf ) how to connect same database in 2008 sql server . please help me its very urgent 
    Hi,
    You cannot attach or restore(if you have a backup) msf and ldf file of SQL Server 2012 to SQL server 2008 its not allowed it will flash error. If its urgent you need to manually script out table definition with constraints and then create same table in SS
    2012 and then transfer data using import/export wizard
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Articles

  • SqlServer 2008 Database Status Showing(Recovery pending)..How to get this database in online?

    SqlServer 2008 Database Status Showing(Recovery pending)
    How to get this database in online?
    This is SharePoint Content database.
    Badri

    SqlServer 2008 Database Status Showing(Recovery pending)
    How to get this database in online?
    This is SharePoint Content database.
    Badri
    Hi,
    Please try running below in master database
    restore database db_name with recovery
    Chances are that this command would not succeed because I guess there was corruption in database and you restarted SQL Server service. Or can you please tell how your database went into recovery pending state.
    Please check SQL Server errorlog you would find information regarding this change. Please post relevant log information here. Please check event viewer as well
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • Databases in Recovery Pending state

    Dear all,
    Need your expertise to understand bit more. 
    Yesterday i came across databases in "Recovery Pending" state problem.
    Followed too many recommendations form Google but to no avail.
    e.g. http://dbamohsin.wordpress.com/2012/01/23/cannot-detach-a-suspect-or-recovery-pending-database/
    Plucked some leafs from Paul Randal's articles as well http://www.sqlskills.com/blogs/paul/post/Search-Engine-QA-4-Using-EMERGENCY-mode-to-access-a-RECOVERY-PENDING-or-SUSPECT-database.aspx
    But none of them could fixed my problem. 
    What i did:
    I installed 2008 r2 on a machine (DEV) which already had 2008; yea instance name was different.
    Had to restart the server so i did (yea, i gave all developers enough time but due to some reasons databases were in recovery pending mode).
    After restart, some databases (not all) were in recovery pending state. Above links provided enough stuff to recover them but didnt work. For instance after setting database in Emergency mode, it stayed there for ages telling something like "Database is
    being recovered, wait until recovery is finished".
    How i fixed it:
    I attached them onto the newly created 2008 r2 instance. Made them offline (on old instance) in case there is any access conflict. Didnt get any error, like files are in use or something,  while attaching them (which raised an eyebrow).
    Couple of things i noticed after new instance's installation:
    While trying to reattach database on same old instance, I wasn't able to see the .mdf and .ldf files form there respective drives. But i was able to see from the new instance.
    WHY?
    Both sql server services (old and new) were using same service account. When i gave service account enough ntfs permissions on the drive i was able to see all .mdf and .ldf files.
    Questions are:
    1) Why it wasnt the case before? Important to note here: service accounts were local admins on the server.
    (I think i am answering myself here...would love to get more insight on it).
    2) Is it normal that i just have 2008r2 tools in Start>>Program. e.g. there is just 2008 r2 management studio not 2008 one etc.
    Dont want to let this happen in production environment (i will have backups though), so is there any approach you guys are using to avoid it.
    I hope i made myself clear here, or let me know.
    Thanks in advance for any help.
    Dinkar Chalotra

    If you dont need your log file, you can:
    Detach your database
    Move the log file to other place
    Attach back the database and from the file list, remove the ldf
    SQL server will create a new log file and the database will be online again.
    Escarcha

Maybe you are looking for