Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

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

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 4:41 PM
Points: 1,770, Visits: 3,202
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.

Thanks

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

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
Check the following link which might help you:

http://www.sqlservercentral.com/Forums/Topic782209-24-1.aspx
http://www.sqlservercentral.com/Forums/Topic1041837-357-1.aspx
http://community.spiceworks.com/topic/282881-automated-restore-of-sql-2008-database

HTH


---------------------------------------------------
"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


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 3:39 PM
Points: 15,618, Visits: 27,998
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

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

Add to briefcase

Permissions Expand / Collapse