How To Perform Scheduled Backups For SQL Server 2005 Express

SQL Server 2005 Express edition is a free, lightweight and embeddable version of SQL Server 2005 which includes SQL Server Management Studio Express for users to easily manage that databases. Although SQL Server 2005 Express edition supports backup and restore database but it does not supports scheduling backups.

SQLServer

Below are the simple steps to perform in order to enable scheduling backups for SQL Server 2005 Express:

  1. Create a store procedure that allows generate the dynamic backup file name, with types of backup to run such as full, differential or transaction log backups and location of the Backup files.
    USE [master]
    
    CREATE PROCEDURE [dbo].[sp_BackupDatabase]
    @databaseName sysname, @backupType CHAR(1)
    AS
    BEGIN
    SET NOCOUNT ON;
    
    DECLARE @sqlCommand NVARCHAR(1000)
    DECLARE @dateTime NVARCHAR(20)
    
    SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') +
    REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')
    
    IF @backupType = 'F'
    SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName +
    ' TO DISK = ''C:\Backup\' + @databaseName + '_Full_' + @dateTime + '.BAK'''
    
    IF @backupType = 'D'
    SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName +
    ' TO DISK = ''C:\Backup\' + @databaseName + '_Diff_' + @dateTime + '.BAK'' WITH DIFFERENTIAL'
    
    IF @backupType = 'L'
    SET @sqlCommand = 'BACKUP LOG ' + @databaseName +
    ' TO DISK = ''C:\Backup\' + @databaseName + '_Log_' + @dateTime + '.TRN'''
    
    EXECUTE sp_executesql @sqlCommand
    END
    
  2. Create a SQL script to run the backup. In this example, we will backup database master and saved the below SQL script as dbbackup.sql and save in “c:\Backup” folder.

    sp_BackupDatabase 'master', 'F'
    GO
    QUIT

  3. Create a scheduled task in Windows which can be found in Control Panel or Accessories -> System Tools -> Scheduled Tasks or Task Scheduler.

    scheduledtask

  4. Click on Add Scheduled Task or Create Task. Scheduling wizard will be displayed. Click Next, then click the Browse button to find SQLCMD.EXE from “C:\Program Files\Microsoft SQL Server\90\Tools\Binn”.

    scheduledtask2

    In Task Scheduler, define the above in Action tab.

  5. Specify when to perform the task as well as the user name and password to run the operation. Once finished, give the scheduled task a name and save the task.
  6. Click on the “Open advanced properties” to edit the command.

    SQLBackup5

    Type the following command in Run:

    sqlcmd -S serverName -E -i C:\Backup\sqlBackup.sql

    The meaning of the command:

    • sqlcmd
    • -S (this specifies the server\instance name for SQL Server)
    • serverName (this is the server\instance name for SQL Server)
    • -E (this allows you to make a trusted connection)
    • -i (this specifies the input command file)

If you want to test the task which has been created then you can go back to the Scheduled Tasks or Task Scheduler, right click on the task and select “Run”.


3 Responses to “How To Perform Scheduled Backups For SQL Server 2005 Express”

  1. Reuben Barajas
    September 10th, 2009 02:32
    3

    Excellent article, I´ve just modify it a little and now I can make backup of all my DB´s in a single scheluded task.

    Thank you!

  2. Reuben Barajas
    September 10th, 2009 02:31
    2

    Excelent article, I´ve just modify it a little and now I can make backup of all my DB in a single scheluded task.

    Thank you!

  3. pradeep
    August 26th, 2009 20:58
    1

    shah_pradeep@yahoo.in

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

sql server management studio express schedule backup - sql express scheduled backup - sql 2005 express scheduled backup - how to create automatic backup in sql server 2005 - sql 2005 express scheduled backups - sql express 2005 backup - create a daily task backup with microsoft sql server management studio express - sql server 2005 express scheduled backup - sql server management studio express backup schedule - sql server management studio express automated backup - sql server management studio express schedule a task - sql express schedule backup - SQL Express scheduled backups - sql server management studio express daily backup - sql server management studio express scheduled backup - SQL Server scheduler backup Exprss - how to backup transaction log file sql express 2005 - how to schedule automatic backup of database in sql express 2005 - sql server 2005 express backup - sql server 2005 express backups - sql schedule backup .bak - sql server 2005 scheduled backup - how can i execute a .sql backup job in a scheduled task - sql express 2005 scheduled backup - sql database backup sql express - sql 2005 how to backup database and auto delete backups files - sql 2005 express how to set up backup - how to make scheduler backup in sql express 2008 - how to run automatic backups for sql express - schedule backup sql database management studio - run sql script from task scheduler - run .SQL scheduled task SQL 2008 express - howto sql server 2005 backup automatic - transaction log backup sql 2008 express script download - sql server scheduled tasks - sql express 2008 scheduled backup - microsoft sql server management express backup daily db - microsoft sql command to set backup - sql server 2008 scheduled backup - scheduled backup for sql 2005 epress with windows xp - sql server express automatic backup and restore - steps for scheduling automatic backup in sql server 2005 through managment studio - schedule SQL backups studio express 2005 - scheduling backups in sql express edition - how to set sql server schedule backup - ms sql scheduled backup and restore - ms sql 2008 express schedule tasks - download SQL Express 2008 Scheduler - automatic backup sql express - backup sql 2005 express -