Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

How to recover database from .mdf file

$
0
0
create a database ofequal size to the one you're trying to attach
    • shutdown the server (Stop)
    • swap in the old mdf file (replace new .mdf file with .mdf file to be recovered )

Location: C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA

    • bring up the server (start) and let the database attempt to be recovered and then go into suspect mode
    • put the database into emergency mode with ALTER DATABASE
    • run DBCC CHECKDB (dbname, REPAIR_ALLOW_DATA_LOSS) which will rebuild the log and run full repair
  • Your database will be available again but you'll have lost data and the data won't be transactionally consistent

USE [master]

GO

ALTER DATABASE [RdmStoreInformation] SET EMERGENCY

GO

ALTER DATABASE [RdmStoreInformation] SET SINGLE_USER

GO

DBCC CHECKDB ([RdmStoreInformation], REPAIR_ALLOW_DATA_LOSS)

GO

ALTER DATABASE [RdmStoreInformation] SET MULTI_USER

GO

ALTER DATABASE [RdmStoreInformation] SET ONLINE

GO

This is a issue I had to fix and it's solution listed here for your reference(I gathered all the In-formations by surfing web)



Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>