SQL Server Timed procedure
Ok so here is a problem i have...first let me start by saying I am a SQL Server newbie. I am more of a web developer and very much comfortable with开发者_StackOverflow中文版 MySQL and PHP/Ruby...Though I just got a problem with SQL server thrown my way.
Here's the problem
I need to update some tables in a SQL Server database at a certain times (11:55 before the end of the month and 12:05 at the beginning of the month) monthly.
So for example...
Based on a calculation per user i need to have an if then else with math that will do calculation x and update record x
I just need the way to do these ...I was thinking of stored procedures or something along those lines but maybe someone can give me a clearer picture...I need to run this procedure at 11:55 before the end of the month and 12:05 at the beginning of the month...so twice a month....any ideas how to do this or the best tool to use....
SQL Server comes with SQL Server Agent, which allows you to schedule execution of Jobs (whch can be stored procedures).
The simplest approach, if you have the rights, is to write a stored procedure and use SQL Server Agent to execute it on whatever schedule you need.
Other approaches involve writing an external app to do the work and using another scheduling mechanism (Windows Scheduled Tasks, for example) to launch the external app.
Edit
After I saved this answer, it occured to me that this question is probably better answered at Serverfault.com
Are you using MySQL or SQL-Server (The Microsoft product)? You've used both tags.
What you use really depends on your environment. If you are already using a scheduling solution for your business processing, then you should probably stick with that.
Assuming MS SQL Server, if you don't already have a scheduling solution then you'll want to use SQLAgent (along with a stored procedure most likely) to do the scheduling.
SQLAgent is a scheduler that is packaged with SQL Server. It's a separate service that must be running on your server. It's very much integrated with SQL Server though and you can directly call stored procedures or run code in a database. There is a fairly easy to use GUI or you can write code that creates jobs for scheduling.
If you need further clarification on SQLAgent once you've gone through the help then post another question on the specifics and I'm sure that people here can help you set up exactly what you need.
精彩评论