Category: Backup and Restore

  • T-SQL Stored Procedure to Get the Time and Backup File Location of the Last Data Restore

    [sourcecode language=”sql” wraplines=”false”] /* .Synoposis Stored procedure to list the last data restore time AND backup file location for specific online user DB’s. .Last modified 2014-03-24 by Nick Xu .SQL Version 2005+ –Usage EXEC sp__GetlastDataRestoreTime @dbname = ‘DBADB’ GO EXEC sp__GetlastDataRestoreTime GO */ USE master GO /* –For generic setting IF EXISTS (SELECT * FROM…

  • T-SQL Script to Delete Older-Than-N-Days Backups in a Specific Folder

    I’ve noticed there are quite some hits on this post and the old format of the T-SQL code looked a bit messy, so I’ve done a makeover of the script on 2014-04-10. This script requires a not-too-strict security setting for sql server’s service account, because it will have to execute Windows batch commands to achieve…