Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute a stored procedure based on system clock ? 1

Status
Not open for further replies.

beetlebailey

Programmer
Jan 4, 2005
51
US
I have created a stored procedure to reset all the values in my table to zero. I ran it and it works just fine. I would now like to know how to execute it based on the PC's clock (at 15:30 every day) if at all possible. Has anyone ever done this before? Can someone point me in the right direction?

Thanks for any advice
 
There is a thing named "scheduled job" that does exactly what you want. :X

------
Math problems? Call 0800-[(10x)(13i)^2]-[sin(xy)/2.362x]
 
I created a job and saved it. Where did it go so I can edit the parameters ?
Thanks.
 
You could create a executable .bat file and then create a schedule task to run every day @ 15:30

Step 1
Take the content of the stored proc (exclude the declaration to create a stored proc) and create an .sql file.

Step 2
Open notepad and create a .bat file
Write in notepad
OSQL -SSERVERNAME -Usa -Psa -iC:\sql file location.sql

Step 3
Create a schedule task. To run the bat file @ 15:30 every day

Finally
The bat file will then execute every day 15:30 and run the sql file (just like running a stored proc but at a specific time)

Hope this helps :)


THE GOV' NOR
 
OS scheduler is OK for simple tasks. I was thinking about SQL Server jobs (EM -> expand server -> Management -> Sql Server Agent -> Jobs).

------
Math problems? Call 0800-[(10x)(13i)^2]-[sin(xy)/2.362x]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top