Automatic backup of a Database in SQL EXPRESS 2005

Last update on August 28, 2009 11:47 AM by jak58
Published by jak58

Automatic backup of a Database in SQL EXPRESS 2005







If you want to automate a backup of a database in SQL Server Express, there is a simple solution using a .bat. file.
Create a new text file. This file should contain the following information:




SET J=%date:~-10,2% 
SET A=%date:~-4% 
SET M=%date:~-7,2% 
SET H=%time:~0,2% 
SET MN=%time:~3,2% 
SET S=%time:~-5,2% 

IF "%time:~0,1%"==" " SET H=0%HOURS:~1,1% 

SET DIRECTORY=E:\Directory_name\ 


FILE=%DIRECTORY%\name _of_backupfile_%J%_%M%_%A%_A_%H%_%MN%_%S%.bak 

IF NOT exist "%DIRECTORY%" md "%DIRECTORY%" 

cd C:\Program Files\Microsoft SQL Server\90\Tools\Binn 

sqlcmd -S Server_name\SQLEXPRESS -Q "BACKUP DATABASE Name_of_sql_database TO DISK = N'%FILE%' WITH INIT, NAME = N'Automatic back up of database', STATS = 1"





Finally, change the extension. Txt. Bat
  • The E:\Directory_name\ is the location where you want to save your backup .bat file.
  • The name _of_backupfile is the name of the .bat file
  • Finally, the Name_of_sql_database is the name of the database.
    • In addition, it displays the date and time of backup name assigned to the .bat file.
    • Then just create a scheduled task.
Best answers for « Automatic backup of a Database in SQL EXPRESS 2005 » in :
Visual FoxPro and SQL Server ShowVisual FoxPro and SQL Server Visual Foxpro 9 and SQL Server 2005 Is there a better alternative than using Visual FoxPro to manage efficiently a SQL Server? Here's an interesting issue. For more information see the article:...
Backup/Restore Mysql database ShowBackup/Restore Mysql database Backup Restore your database Note A simple approach on how to backup and restore MySQL databases. Backup To save an existing database it is recommended that you create a dump. To dump all...
Download Automatic Backup ShowWhen you lose your data, it is not necessary to persuade your that to possess an effective saving program is the best solution. Automatic Backup is a program which will not only protect your data, but it will also keep the former versions of your...
Introduction - Databases ShowWhat is a database? A database (abbreviated DB) is an entity in which data can be stored in a structured manner, with as little redundancy as possible. Different programs and different users must be able to use this data. Therefore, the concept of...