Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Backup by datetime file name

By Jason S Wong,

It is an optional tool to use SQL Server Maintainence Plan to schedule regular backups of your databases. To take advantages of full control, total flexibility, I use my own scripts to backup databases. Here is an simple example to show how to backup database by the datetime file name. You can simply modify this to run differential backup or to backup log. Put them as SP in AdminDB and schedule Agent Job for it, just that simple. Use my other script to check review disk space. If you have custom request, please email me.


I suggest readers further enhance this script by coding the parameter in database table such as the backup drive letter, use sys.sysservers to get server name, use a loop to pick up active db names (see my other code publication), use xp_cmdshell to create backup directory, use admindb data table to store runtime and status, etc. I have coded comprehansive DB backup scripts I use for the DBs I manage.

Total article views: 1858 | Views in the last 30 days: 6
Related Articles

Powershell Database Backup Script

Learn how to write a script for regular database backups using Powershell and SMO.


xmla script for automate ssas database backup

xmla script for automate ssas database backup


Script to Check the Database Backup duration

Script to Check the Database Backup duration of entire instances


Backup & Restoration Script

This script provides very useful information about database backup and restoration.


Script to Get the Backup History

Script to get the database backup history on SQL Server 2000/2005/2008


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

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones