itauto3 Posted May 24, 2018 Share Posted May 24, 2018 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? Link to comment Share on other sites More sharing options...
Andreik Posted May 24, 2018 Share Posted May 24, 2018 (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 May 24, 2018 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
itauto3 Posted May 24, 2018 Author Share Posted May 24, 2018 I don't understand. I want script to automatically disconnect idle users/connections. Link to comment Share on other sites More sharing options...
itauto3 Posted May 24, 2018 Author Share Posted May 24, 2018 Maybe this will help me also: https://gallery.technet.microsoft.com/scriptcenter/How-to-kill-SQL-Server-a33476b7 Link to comment Share on other sites More sharing options...
Andreik Posted May 24, 2018 Share Posted May 24, 2018 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now