Check the images below to learn how to create a scheduled mssql query task using Microsoft’s Sql Server Management Studio. Red zones are the most important for you to check or to click on and black zones are the ones you not supposed see because screenshots were taken from live server.
real life example:
My client’s community website had a sql table OnlineUsers where every logged in user was stored on login with time user logged in or moved a page last time which was an indication that user is still online. Previously a trigger to delete inactive users was a login of some other user. So each time other user logged in, he triggered delete statement on table where userLastActivityTime was more than 30 minutes ago. In some situation each minute about 20 users users logged in and at night there were almost none. So i came up with idea to create a scheduled sql task that runs each two minutes and deletes users that made no action in 30 minutes. It reduces number of requests in daytime and made night results more precise. In general it reduces amount of unwanted transactions in x times.
pictures:
Tags: sql, sql management