nekies
nekies

Reputation:

how to create a scheduled process in sql server

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?

Upvotes: 0

Views: 1073

Answers (2)

Andomar
Andomar

Reputation: 238086

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

Upvotes: 2

devio
devio

Reputation: 37215

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.

Upvotes: 1

Related Questions