views:

169

answers:

2

In MSSQL Server 2008, how would I go about creating a scheduled process that:

Takes the sum of a float column from specific users in a user column and then comparing which is has the greatest sum and storing that number along with the user whom has that value into a separate table on a weekly basis?

+1  A: 

Personally I prefer to write a service which performs actions periodically, since I have better control of when the actions are to be executed, and everything is in a single place.

If you want to solve your problem with database means only, just create a stored procedure implementing your logic, and call that stored procedure from a scheduled job.

devio
+2  A: 

Create a SQL Server scheduled job that executes a stored procedure or raw SQL.

Based on your description, the query could look like this:

insert into table (username, sumofcolumn)
select top 1 username, sum(column)
from table2
group by username
order by sum(column) desc
Andomar
I agree, triggers should not be used for tasks that have to run on a scheduled basis like 'once a week'
edosoft