Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

restore database from another database script Expand / Collapse
Posted Wednesday, February 26, 2014 1:43 PM


Group: General Forum Members
Last Login: Yesterday @ 4:12 PM
Points: 1,975, Visits: 3,706
I would like to set up automated job to restore a database from another live database nightly.

I can use SSMS UI to restore the database to point of time from the other live database.

Is there a way that I can do from script?

I can do something like below (pseudocode)

restore databaseA from database B
to point of time of tonight 9:00 pm.

I don't want to use the backup file names, for every night the backup name changes.
Just use the database name.


Post #1545573
Posted Thursday, February 27, 2014 3:15 AM


Group: General Forum Members
Last Login: Thursday, March 17, 2016 5:13 AM
Points: 2,796, Visits: 2,232
Check the following link which might help you:


"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #1545776
Posted Thursday, February 27, 2014 6:15 AM



Group: General Forum Members
Last Login: Yesterday @ 12:16 PM
Points: 17,064, Visits: 31,952
I'd suggest using a T-SQL script to restore from. Whatever mechanism is changing the backups nightly is surely discernable, and therefore repeatable. You can then just run the restore. There is no RESTORE FROM Database command. You must have a backup. If you have to, you could take a backup of your own, but then, in case you have differentials, make sure you use COPY_ONLY for that backup so that it doesn't disrupt the differentials.

"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server Query Performance Tuning
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1545821
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse