SQL2012 database issue... very bizarre

Status
Not open for further replies.

MichaelC

Ars Legatus Legionis
34,233
Have a really bizarre issue. Somehow SQL has gotten out of sync with what the data and log file names should be. I have several databases in a Reovery Pending state. The logs show that SQL either cannot find the files or that fileX is not a primary database file. This was such a strange thing. I queried the system database and found entries like the following:

foodb foodb e:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\foodb_log.ldf
foodb foodb_log E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\foodb_log.ldf

What this is showing is that in this particular instance, both the data file and the log file are the same name.

The correct databases files do exist on the file system in the correct path:

foodb.mdf
foodb_log.ldf

This is going back beyond the number of backups I have. So I have to work with what's in front of me.

The system databases, master, model, msdb, tempdb are not affected by this. I can access the SQL instance, but most of the databses are in this state.

The databases are offline or rather in a recovery pending state. So if I try to use an alter statement to change the path to the correct file name, I get an error because the database cannot be accessed by SQL. My understanding is that the logical name and path and file name are in the database... the data file. What I am wondering is if I can tell SQL... the master to use the files I actually have present without having to alter the databases I cannot access.
 
Status
Not open for further replies.