Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Build Restore Scripts for All User Databases

By Neil Jacobson,

Something I really hate is typing something repetitive.  To prepare for our Disaster Recovery plan, I wrote this script.
It is a bit strange in that it requires 2 run iterations to generate the desired result.

I use a naming standard for backup files of the form:

D_DBName.Bak

and a naming standard for database files of the form:

DBName_Dx.Mdf for Primary filegroup file
DBName_Ix.Ndf for Index filegroup file
DBName_L1.Ldf for Log file

I also use a directory structure the same on every volume of the form:
SQL8
     Backup
     Data
     Index
     Log

Well you get the picture.  You can modify this to suit yourself.
To use, run it. Take results and run it. The last set of results are your restore scripts.

Total article views: 532 | Views in the last 30 days: 4
 
Related Articles
FORUM

Result Set

Result Set

FORUM

SSMS Results

Consolidate SSMS Results

FORUM

ORDER Result

ORDER a Result

FORUM

how to group my results

grouping results

SCRIPT

Split by a row (count) number of a query results

Query results splitter

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones