How to create scheduled process in sql server

In MSSQL Server 2008, how would I start to create a scheduled process that:

Takes the sum of a float column from specific users in a user column and then a comparison which has the highest sum and stores that number along with the user who has that value in a separate table on a weekly basis?

0


a source to share


2 answers


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

Based on your description, the request might look like this:



insert into table (username, sumofcolumn)
select top 1 username, sum(column)
from table2
group by username
order by sum(column) desc

      

+2


a source


Personally, I prefer to write a service that periodically performs actions as I have better control over when actions should be performed and everything is in one place.



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

+1


a source







All Articles