Recovering SQL database when OS crashed

All we need is an easy explanation of the problem, so here it is.

I was working on a DB design its almost finished. But missed to take a backup.
While working due to some reason my OS got crashed (Win 10) and nothing helped to recover it.

But I am able to access the hdd contents when connecting in another PC.

So is there is anyway to recover the DB using an SQL server express installation on that PC.

On googling I have found there is some attach option using MDF files

But I am not able to find the MDF files in the Program Files\MS SQL server folder

Where SQL server express 2019 is storing MDF files by default?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Your best bet is to use a file search tool, such as AstroGrep, since the database file paths could be set to anywhere, depending on what was chosen when the database itself was created (after the SQL Server instance was installed).

Otherwise you can find information regarding the default paths of SQL Server in Specifying File Paths docs.

You’ll want to take all MDF, NDF, and LDF files pertaining to your database(s) together. Then you should be able to Attach them to a new SQL Server instance by following these instructions per Microsoft.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply