Home Forums SQL Server 2008 SQL Server Newbies SQL Server Express Does Not Provide A Way to Setup Maintenance Plans RE: SQL Server Express Does Not Provide A Way to Setup Maintenance Plans

  • I just completed setting up an automated backup of SQL Express databases, so I'll share what I did.

    The Maintenance Plans and SQL Agent are not available in SQL Server Express. You will not have a GUI to work with, so knowledge of TSQL scripting is a must. The good news is that if you are not strong in TSQL, if you have access to SQL Server Standard or higher, you can setup similar plans within the GUI and script them out. Then you can edit to fit your express instance(s). There is also a wealth of information out there on "the net", just Google away.

    First, create a blank text file to hold the TSQL commands. I called mine "SQLExpressBackups.sql". Then edit that file and place the maintenance commands you want to run in it. For example...

    USE [master]

    GO

    BACKUP DATABASE MyDatatbase TO DISK = N'X:\Backups\MyDatabaseBackup.bak' WITH NOFORMAT, INIT, NAME = N'MyBackup';

    GO

    After you have all of the TSQL commands you need, save the file and create another blank text file. This next text file will actually be a BAT file, so be sure to save it with the .bat extension. I named mine "sql_backup.bat". Edit that file and place the SQLCMD command that will execute the backup/maintenance commands you created in the first step. Example:

    "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -S(local)\your_instance_name -UBackupOperatorUserName -PBackupOperatorPassword -i c:\backup\SQLExpressBackups.sql

    The final step is to create a task in Windows' Task Scheduler that will execute the *.bat file you created on the schedule you need.

    One "gotcha" with any of this is permissions. Be sure the operator you specify in the bat file after -U has permissions to perform the jobs you are scheduling. Additionally, be sure the user you specify in Task Scheduler has permissions needed to execute the bat file.

    Good luck, I hope this works for you or you found your answer elsewhere.