Reputation: 164
I have a folder with more than 300 .mdf and .ldf microsof SQL server database files(recovered from a ransomware attack to our ESXI server then I have no access to SQL server Master db)
Without access to SQL server system databases to fetch database names and ..., How can I bulk convert all these database files to SQL server backup (.bak) files with no need to manually attach them one by one to sql server in SQL management studio.
Upvotes: -2
Views: 279
Reputation: 442
You won't be able to convert the MDF/LDF to a BAK file, so you are going to need to reattach the databases.
The database name is usually in the file name; do you know the structure of these databases - did they have more than one data/log file for example?
You could use Powershell to generate a list of discrete names using:
And then iterate through that list and use Invoke-SQLCMD to run the CREATE DATABASE FOR ATTACH commands using:
Upvotes: 1