Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: 541 | Views in the last 30 days: 2
 
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