SQL Server – Run Scheduled Scripts without SQL Agent

Here’s a really useful article on how to schedule backups and to run SQL scripts without using SQL Agent.

http://www.diaryofaninja.com/blog/2011/02/14/howto-quick-amp-dirty-sql-express-scheduled-backup

This is particularly relevant for SQL Server Express installations where agent isn’t available.

The pertinent part of this is using Windows scheduler to execute the a .sql script via SQLCMD.

SQLCMD.EXE -S .\sqlexpress -E -i C:\DbScripts\BackupDatabases.sql

Another tip I’ve picked up recently is using the Windows forfiles command to delete files over x number of days. Here’s the example syntax.

FORFILES /P C:\MyPath\ /S /M *.bak /D -5 /C “cmd /c del @file”

About dotnettim

Tim Leung is a Microsoft .Net / SQL Server developer based in England.
This entry was posted in SQL Server. Bookmark the permalink.

1 Response to SQL Server – Run Scheduled Scripts without SQL Agent

  1. Thanks for the link, I’m glad you enjoyed the post!

    Like your blog, keep up the great work!

Leave a comment