October 17, 2017 at 4:48 am
I am facing a situation like this:
I some ndf files deleted accidentally and the latest backup refers to yesterday
I create the same database and overwrite main database files on new one.
then :
ALTER DATABASE [MyDb] SET EMERGENCY;
GO
ALTER DATABASE [MyDb] SET SINGLE_USER;
GO
DBCC CHECKDB (N'MyDb', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;
but I gave this error :
One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.
How can I recover this database?
October 17, 2017 at 5:10 am
Do you take log backups? If you have your full backup from yesterday then restore your logs up to the point where the data files were deleted.
Thanks
October 17, 2017 at 6:33 am
If files that are part of the database (the NDFs) were actually deleted, your only option is to restore from backup. That's not "corruption" such as can be (potentially, often with data loss) repaired.
As NorthernSoul asked, if you take log backups, you can at least recover up to close to the time the NDFs were deleted.
October 17, 2017 at 7:24 am
I don't know how you deleted your NDFs accidentally, but if you did so on the server, check the recycle bin. I know it sounds simple, but we don't know what happened except for what you tell us. You might just get lucky with this one.
If you don't have the files themselves, then restore from backup like others have said.
October 28, 2017 at 5:15 am
This was removed by the editor as SPAM
October 28, 2017 at 9:51 am
farax_x - Tuesday, October 17, 2017 4:48 AMHow can I recover this database?
Restore from backup. You cannot mix and match data files.
If the DB is in full recovery, you can take a tail-log backup and lose nothing. If it's in simple, you'll lose data back to the last full backup.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply