SQLTeam.com | Weblogs | Forums

How tro restore many databases with one comand or script?

Dear members

I have more than 20 databases to restore

how can I do restore all the banks at once?

anybody have script to help me ?

Thanks
Almir

If you are familiar with how to restore a database using the SSMS user interface, you can create the script yourself. To do this, use the user interface as though you are going to restore, select all the options, and instead of clicking the OK button to start the restore process, click the script button at the top left of the window. This will create a script with all the options, filenames etc. You can use this script to restore the database.

If you have 20 databases, you can repeat the process for each database, or take the script for one that you created and replicate it after making appropriate name changes.

I'd also look into the PowerShell dbatools (https://dbatools.io/). I've been using those for backup and restore around DEV databases and I've been very happy with it.