« Best way to delete millions of rows SQL Server Stored Procedure | Main | Kill connections for specified database »
Wednesday
Oct182017

Stored Procedure to Restore SQL Database

Note: requires sp_rcb_killtargetdbconns (below)

Whenever I'm restoring a SQL database I hate using the GUI and meticulously having to browse out to each file needed in the recovery effort. So I wrote a SPROC that takes a few parameters (i.e. the path to my backup files). Works great for seeding secondary Availability Group replicas or just recovering a database.

It's called sp_rcb_PitrRestore and you run it like this:

The full SPROC follows. As the comments allude to please note that the latest full backup in you @BackupsFolderFull value is the one you want to use in your restore. Also be sure to check that your filename suffixes (i.e. .BAK, .DIF, et cetera) match what's in the SPROC.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>