I am running Microsoft SQL Server 2012 on a Windows 7 Home Premium OS. I encountered a state of a database being in "Recovery Pending" mode. I am going to go over the details of how this happened. I was using SQL Server Configuration Manager to stop "SQL Server (MSSQLSERVER)" because I wanted to delete the file "C:\Temp\FileTableExampleDB_FileStreamFile". I was trying to get the following query to work:
USE [master] GO ALTER DATABASE [AdventureWorks2012] ADD FILEGROUP [FileTableExampleDBFilestreamFG] CONTAINS FILESTREAM GO ALTER DATABASE [AdventureWorks2012] ADD FILE ( NAME = N'FileTableExampleDB_FilestreamFile', FILENAME = N'C:\Temp\FileTableExampleDB_FilestreamFile' ) TO FILEGROUP [FileTableExampleDBFilestreamFG] GO USE [AdventureWorks2012] GO IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = N'FileTableExampleDBFilestreamFG') ALTER DATABASE [AdventureWorks2012] MODIFY FILEGROUP [FileTableExampleDBFilestreamFG] DEFAULT GO USE [AdventureWorks2012] GO ALTER DATABASE [AdventureWorks2012] REMOVE FILE [FIleTableExampleDB_FilestreamFile] GO
Previously, I ran the above query and encountered some errors when running the code. The file "C:\Temp\FileTableExampleDB_FileStreamFile" was created in the process. I wanted to delete "C:\Temp\FileTableExampleDB_FileStreamFile" because otherwise, the compiler would complain that "C:\Temp\FileTableExampleDB_FileStreamFile" was already created. I tried to delete this file manually, but I get an OS error that the file is being used by MSSQLSERVER. Therefore, I decided to stop MSSQLSERVER using SQL Server Configuration Manager. I did that, deleted the file successfully and restarted MSSQLSERVER. Unfortunately, the database AdventureWorks2012 changed its status to "Recovery Pending". Can you give me the easiest way to resolve this without deleting AdventureWorks2012? Thank you.