user1464251
user1464251

Reputation: 333

Is it possible to read the database name from a mdf file that is not attached to a sql server

I have a batch file I am running to shrink a large number of detached database log files. I first attach the database with a "default_database_name", then shrink the database, then detach it again and move onto the next database.

This accomplishes shrinking all my log files, however, then all my databases end up having the same logical database name. I am trying to avoid this.

Any ideas?

Upvotes: 0

Views: 689

Answers (1)

steoleary
steoleary

Reputation: 9278

You can see this information, but you will have to use a hex editor to see it, for the databases I tested with I opened the MDF with a hex editor (HxD was the one I used) and the database name was visible at around offset 00000E20-00000E30:

Hex Screenshot

Upvotes: 1

Related Questions