Question

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?

Was it helpful?

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.

OTHER TIPS

The accepted answer of Sys.Databases will not give you the physical file location. For anyone looking still for it, you need to query:

SELECT [name], [physical_name] FROM sys.database_files
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top