Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
engisa
Starting Member
2 Posts |
Posted - 2010-01-11 : 08:24:01
|
Hi,I wanted to execute the query stored in a table with given intervals.I have a table called "calculations". it has the following structure:id | period | sql | result |now, in the sql field, I store the sql clause to be executed. In the period field, there is time interval for the query to run. Result field stores the result of the sql clause.Example:1 | 5 | select count(*) from mytable | 1this means that every 5 minutes, take the given query, execute it, and update the result field.I could not find a way to do this. Can anyone help?Thanks... |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-11 : 10:47:45
|
why have you gone for such a system design? why store statements like this in a column? |
|
|
engisa
Starting Member
2 Posts |
Posted - 2010-01-11 : 13:36:10
|
Because we have very complicated select count() queries in one page. When a user logs in, every query works independently and the databse becomes very slow. The site is very active, hence these queries makes the system very slow...However, in this design, we will have queries executed once in 5 minutes, hence when a user logs in, we will just read the value of result field of the corresponding query. I think there must be a way for these...Any suggestions?Thanks in any way... |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-11 : 13:42:25
|
What is about putting a statement like below in a job in sql server agent and schedule it for every 5 mins?update calculations set result=(select count(*) from ...)where id=1 No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
|
|
|
|
|