Jump to content

Recommended Posts

Posted

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? 

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

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
×
×
  • Create New...