Search code examples
sql-serverrecovery

SQL Physical Database File Location (Recovery)?


I just recently changed out all my hard drives and in the process of setting up some projects again I noticed that the database file I was backing up was actually the wrong file as it only contains 30% of the database that I had running. I have my old drives and all the data should be intact but I've been unable to actually locate the correct database file...

Is there any way that I can read the physical file location from the dead SQL Server?


Solution

  • get the master database from the old SQL Server instance and attach it to the new system, or restore a backup of the master database, so you can query it. (just dont overwrite/replace the live system's master db!)

    SELECT [Name], FileName FROM sysdatabases

    will get you a list of the databases on that server, and the full file paths.