debugsqlMinor
How to rename logical file names in recovery pending database that cannot be recovered?
Viewed 0 times
cannotfilenamesdatabaserecoveredrecoverypendingthathowlogical
Problem
Here's the situation:
I tried to rename the logical file with a script (
Database 'A_OLD' cannot be opened due to inaccessible files or
insufficient memory or disk space.
There is disk space and memory. If I set offline/online this does not work, because it keeps trying to attach the database to the new one's file which is using it. Also tried to copy the mdf file and manually attach it using SSMS but it does not work because it looks for the file without the
I'm running out of ideas. Is there any way to recover this database?
- Someone renamed database
AtoA_oldin SSMS
- They did not rename the physical nor logical file; physical file was renamed somehow to
A_old.mdf
- They then created a new database called
Athat hasA.mdfas filename
- However
A_olddatabase is now in recovery mode because it still has logical file nameA.mdf
I tried to rename the logical file with a script (
ALTER DATABASE ... MODIFY FILE), getting and not getting the database offline, as admin in SSMS, but still getting an error:Database 'A_OLD' cannot be opened due to inaccessible files or
insufficient memory or disk space.
There is disk space and memory. If I set offline/online this does not work, because it keeps trying to attach the database to the new one's file which is using it. Also tried to copy the mdf file and manually attach it using SSMS but it does not work because it looks for the file without the
_old suffix.I'm running out of ideas. Is there any way to recover this database?
Solution
If your goal is to have both databases co-exist then I would try the following:
- Take both the
Adatabase andA_olddatabase offline if possible.
- Make copies or temporarily move their MDF and LDF files. (This is a precautionary measure and may be a little overkill.)
- Drop the
A_olddatabase.
- Put back the MDF and LDF files of both databases.
- Turn
Aback online (and make sure it's still working properly).
- Attach a database and select the MDF and LDF for
A_oldwhich if I understand you correctly is now called "A_old.mdf" (note the LDF file will need to have a different name than the newAdatabase's LDF file too).
- Verify
A_oldis working properly now.
Context
StackExchange Database Administrators Q#308429, answer score: 2
Revisions (0)
No revisions yet.