By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,940 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,940 IT Pros & Developers. It's quick & easy.

Run a stored procedure every quarter

P: 102
I have a stored procedure that needs to run on the first day of every quarter. Can someone point me in the right direction?

Sep 30 '16 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 983

Here is a recipe that I might suggest - write a batch file that runs the procedure, and then schedule the file to execute quarterly using the windows task scheduler.

My example script is designed to do everything self-contained. Needless to say, it is just a thin example, which you should expand to include all the necessary complexity.

Good Luck!


You should run a scheduled task in the Windows Task Scheduler or Windows Task Scheduler (uSloth Dev Page)

Here are some examples:
Google Query: windows task scheduler script example.
To write a database scripting file, try something like this (Quarterly.bat) (ref: Use the sqlcmd Utility):
Expand|Select|Wrap|Line Numbers
  1. @echo off
  2. rem 
  3. rem Quarterly.bat
  4. rem   - invoke for quarterly maintenance 
  5. rem 
  6.   rem -- local variables
  7.   set DATA_BASE=DataBaseName\MySchema
  8.   set FILE_OUTPUT="C:\Quarterly.output"
  10.   set USER="user"
  12.   rem -- do the nasty
  13.   sqlcmd -S %DATA_BASE% -U %USER% -o %FILE_OUTPUT% -Q %QUARTERLY_SQL%
  15. rem 
  16. rem -- end of fyle
  17. rem
Oct 2 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.