My next question, How to setfilter "duration" datatype? as we know that duration has value for day,hour,minutes,second.
for e.g 1 day 5 hours 40 minutes 8 seconds. How to filter idle time in session table for more than 2 hours ?
With SQL Server you could also kill idle session with some TSQL:
use [master]
go
set statistics io off
set nocount on
go
declare @threshold datetime
set @threshold = dateadd(hour, -6, getdate()) -- threshold is 6 hours ago
print 'Killing processes which executed "Last Batch" before ' + convert(varchar(30), @threshold, 113)
print ''
declare @spid int, @last_batch datetime
declare spid_cur cursor for
select [spid], [last_batch] from sysprocesses
where [program_name] = 'Microsoft Business Solutions-Navision client' -- change application name here
and [last_batch] <= @threshold
open spid_cur
fetch next from spid_cur into @spid, @last_batch
while @@fetch_status = 0 begin
print 'Killing process ' + convert(varchar(5), @spid) + ', idle since ' + convert(varchar(30), @last_batch, 113)
exec ('kill ' + @spid)
fetch next from spid_cur into @spid, @last_batch
end
close spid_cur
deallocate spid_cur
go
This script searches for NAV processes which have executed the last batch 6 hours ago (please change the settings if applicable) and kills them. YOu could create a SQL Agent job which execute this script every hours.
If necessary you have to add some exception handling etc..
Comments
http://www.mibuso.com/howtoinfo.asp?FileID=18
or article below...
viewtopic.php?t=26024&highlight=session+kill
-Lavin
"Profanity is the one language all programmers know best."
I got the clue now...
My next question, How to setfilter "duration" datatype? as we know that duration has value for day,hour,minutes,second.
for e.g 1 day 5 hours 40 minutes 8 seconds. How to filter idle time in session table for more than 2 hours ?
session.setfilter("idle time", ???);
I've already got the answer... \:D/
Thanks....
This script searches for NAV processes which have executed the last batch 6 hours ago (please change the settings if applicable) and kills them. YOu could create a SQL Agent job which execute this script every hours.
If necessary you have to add some exception handling etc..
USE AT OWN RISK!
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool