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)

Script to Restore Entire database from a directory

By sathish NS,

Script gives the autommatted SQL script's on Restore FileListonly, Restore Headeronly and Backup Restore script from the backup drive(ie Gets the restore script for all the available backup files from the specified drive).

Contains two stored procedures,need to create both the stored procedures and run the first procedure to get the restore scripts from the available backup files,
1. USP_DatabaseRestorewithPhysicalPath - Gives the restore script including Headeronly, FileListonly,  and inturn calls Stored procedure "restoreDB" to actual Restore Database script. Need
2. restoreDB - Called from the above stored procedure to produce Restore database script.

Execute Stored procedure with the backup path parameters,

Execute USP_DatabaseRestorewithPhysicalPath 'D:\MSSQL\Backup'

Sample Outputs from the available backup file directory,

--D:\MSSQL\Backup\BACKUPDEMO_DIFF.BAK

RESTORE FILELISTONLY FROM DISK = 'D:\MSSQL\Backup\BACKUPDEMO_DIFF.BAK'

RESTORE HEADERONLY FROM DISK = 'D:\MSSQL\Backup\BACKUPDEMO_DIFF.BAK'

Exec [restoreDB] 'BACKUPDEMO','BACKUPDEMO','D:\MSSQL\Backup\BACKUPDEMO_DIFF.BAK'

GO

----------------------------------------------------------------------------

--D:\MSSQL\Backup\BACKUPDEMO_FULL.BAK

RESTORE FILELISTONLY FROM DISK = 'D:\MSSQL\Backup\BACKUPDEMO_FULL.BAK'

RESTORE HEADERONLY FROM DISK = 'D:\MSSQL\Backup\BACKUPDEMO_FULL.BAK'

Exec [restoreDB] 'BACKUPDEMO','BACKUPDEMO','D:\MSSQL\Backup\BACKUPDEMO_FULL.BAK'

GO

Total article views: 2442 | Views in the last 30 days: 21
 
Related Articles
SCRIPT

Backup & Restoration Script

This script provides very useful information about database backup and restoration.

FORUM

Script to restore red gate backups automatically from a folder.

Restore of red gate backup files using a SQL Script

SCRIPT

Restore Script Generator

Create restore script from a SQL Backup file. A must have for your DBA Tool Belt.

BLOG

Generate restore script automatically by backup history table

I wrote a store procedure which could generate restore script automatically by backup history table....

FORUM

Backup/restore

Backup/restore

Tags
restore    
 
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