HOWTO: Schedule MSSQL query task

Check the images below to learn how to cre­ate a sched­uled mssql query task using Microsoft’s Sql Server Man­age­ment Stu­dio. Red zones are the most impor­tant for you to check or to click on and black zones are the ones you not sup­posed see because screen­shots were taken from live server.

real life example:

My client’s com­mu­nity web­site 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 indi­ca­tion that user is still online. Pre­vi­ously a trig­ger to delete inac­tive users was a login of some other user. So each time other user logged in, he trig­gered delete state­ment on table where user­Las­tAc­tiv­i­ty­Time was more than 30 min­utes ago. In some sit­u­a­tion each minute about 20 users users logged in and at night there were almost none. So i came up with idea to cre­ate a sched­uled sql task that runs each two min­utes and deletes users that made no action in 30 min­utes. It reduces num­ber of requests in day­time and made night results more pre­cise. In gen­eral it reduces amount of unwanted trans­ac­tions in x times.

pic­tures:

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • LinkedIn
  • StumbleUpon
  • Technorati
  • Live
  • PDF

Tags: sql, sql management

Leave a comment