Scheduling a Script to Clear SQL Server Sessions Daily

Overview

This article provides the steps to be followed to configure the SQL Server Job Scheduler utility to execute a T-SQL script that clears all sessions every day at the specified time.

 

Information

Follow the steps below to schedule a T-SQL script to clear all server sessions every day at the specified time:

  1. Expand the SQL Server Agent node and right-click the Jobs node in SQL Server Agent and select 'New Job'

  2. In the 'New Job' window enter the name of the job and a description on the 'General' tab.

  3. Select 'Steps' on the left pane and click 'New' at the bottom.

  4. In the 'Steps' window enter a step name and select the database you want the query to run against.

  5. Paste in the T-SQL command "DELETE FROM EVEREST_SPM WHERE UID IN (SELECT UID FROM EVEREST_SPM WHERE ATTRIBUTE = 23 AND VALUE = 7)" to run into the Command window and click 'OK'.

    Tip: The above T-SQL query can be customized to execute any appropriate script depending on the customer's requirements.
  6. Click on the 'Schedule' menu on the left pane in the New Job window and enter the schedule information as desired (e.g. daily and time 3 AM EST).

  7. Click 'OK' to schedule the job.

Below is an animated GIF of the above steps created using MSSQL Server 2012:

MViKk.gif

Back to top

Comments

0 comments

Please sign in to leave a comment.