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”
Advertisements

About dotnettim

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

One 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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s