Jump to content
Sign in to follow this  
itauto3

Disconnect MS SQLSerever2008 idle users/connections

Recommended Posts

itauto3

Is there any way to write a script (it maybe already exists), that would disconnect users/connections, that are connected to MS SQLServer2008 database, if they are idle e. g. for 10 minutes? 

Share this post


Link to post
Share on other sites
Andreik
Posted (edited)

Your question is more related to databases not AutoIt. Anyway, you can use any AutoIt UDF for SQL to call a script like this one:

SELECT *
FROM sys.sysprocesses
where status IN ('sleeping')
and cmd IN ('AWAITING COMMAND')
and kpid = 0
and spid > 50
and db_name(dbid) not in ('master','tempdb','model','msdb')
and datediff(mi,last_batch,getdate()) > 10

Make a cursor and kill each session.

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
itauto3

I don't understand. I want script to automatically disconnect idle users/connections. 

Share this post


Link to post
Share on other sites
Andreik

I already told you to create a cursor or a loop to kill each session returned by the query.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×