Wednesday 25 February 2015

1.22 - Identifying A Database From The Data File

A few times in the past I have had to deal with trying to identify a detached data file and try to work back as to what database the files belonged to.
After a lot of searching, I have long last found the solution and I hope it comes in helpful to those in a similar position to myself.

Enjoy!

Syntax:DBCC CHECKPRIMARYFILE ({'PhysicalFileName'} [,opt={0|1|2|3}])

PhysicalFileName is the full path for the primary database file.

opt=0 - checks if the file a primary database file.
opt=1 - returns name, size, maxsize, status and path of all files associated to the database.
opt=2 - returns the database name, version and collation.
opt=3 - returns name, status and path of all files associated with the database.

REM: You need the security on the folder/file to read the info!

No comments:

Post a Comment