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 determine backup finish times

By lhughes92,

SQL Server provides the RESTORE HEADERONLY command which helps users determine backup completion times.  What if you have the need to use this completion time for comparison, perhaps to set up a job that only restores the file if it is xx hours old.  This script can be used to determine the maximum backup finish date for a particular file.  The script reads this field from the backupset system table in the msdb database.  It then joins to the backupmediafamily table to allow the user to specify the exact physical device location.  Make sure to use the full path to the location of the device.  After this code completes, you can compare @FinishDate to the current date (using GETDATE) to determine if the file should be restored.  These steps can be placed in a SQL Server job, then scheduled for easy administration.

Total article views: 356 | Views in the last 30 days: 2
 
Related Articles
SCRIPT

List database restore COMPLETION datetime

This script shows the COMPLETION datetime of database restore.

FORUM

Restore log with standby option takes too long to complete!

Restore using "with standby " takes too long to complete

BLOG

Day 3 of 31 Days of Disaster Recovery: Determining Files to Restore Database

Day 3 of 31 Days of Disaster Recovery: Determining Files to Restore Database 31 Days of Disaster ...

FORUM

Determining a database's completed restore date and time...

I am familiar with the various queries that can be run to return information out of the 'msdb' datab...

FORUM

SQL 2008 Restore Never Completes

SQL 2008 DB flagged as "Restoring" for 1 day and counting...

Tags
 
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