Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to restore about 1000 backups with the latest diff (for about 1000 databases). Some data was deleted last night in one column of a table. So I need to run a script on each restored vs current database to repair the data loss.

I know how to get a restore script via the Sql Server Mgmt Studio GUI, but how can I get a restore script for all the databases on the server?

Perhaps, there is a SELECT statement I could run to get full backup file path and latest diff file path for every database on the server. If you know how to do this, let me know.

(And yes I know to just do restore a database one at at time, and then delete to conserve space, but I still need to automate because there are about 1000 databases).

share|improve this question
up vote 2 down vote accepted

I think this two articles might help you to build your own version

Auto generate SQL Server restore script from backup files in a directory

Auto generate SQL Server database restore scripts

Good Luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.