Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am migrating SQL Server DBs to a new instance.

I have been told that it is possible to dynamically build a RESTORE script from available backups in the system catalog.

Does anyone know of a sample script to do this?

Thanks!

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I, personally, use sp_restorecriptgenie by Paul Brewer. Here's the link to the SCC article that has it. Under 'The Procedure'

http://www.sqlservercentral.com/articles/Restore+database/95839/

Basically, once you build the sproc, just run exec sp_restorescriptgenie and the script will go out and get all backups for every DB (even transaction logs) and give you a script to generate them. Also generates the DBCC CHECKDB commands to check the DBs after restoring.

I actually just used this script about an hour ago so i can do a test restore and verify my backups.

share|improve this answer
1  
FYI .. Its on SCC –  Kin Jul 31 at 15:27
    
Ah-ha! I must have scrolled right past it. Answer updated. –  Kris Gruttemeyer Jul 31 at 15:29
    
Do you know if this will handle multiple backup files? –  Kenneth Fisher Jul 31 at 16:20
    
As in full/differentials and transaction logs? If so, then yes. –  Kris Gruttemeyer Jul 31 at 16:26
    
Actually I was meaning multiple full files, multiple diff files (striping the backup). I checked though and it does. I tested with 4 files (it claims to do up to 10). –  Kenneth Fisher Jul 31 at 16:43

Your Answer

 
discard

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.