How to select the RTC client session with the biggest idle time to kill with STOPSESSION?
gycsiak
Member Posts: 19
Hi there,
Does anyone know how to query from Dynamics NAV code the system tables or session tables to get to know, which session is idle for the longest time and so to kill it via STOPSESSION, but to leave out Users with a custom boolean flag like "Protected", so that nevertheless, one of these users are idle for the longest period, but my code wouldn't run STOPSESSION on these users' session.
Thanks anyway, but I would like to do this from NAV NAS, not from SQL directly, if possible, searched and googled it for a long time, so now I think I ask the forum, thank you in advance!
Best regards,
Gyula
Does anyone know how to query from Dynamics NAV code the system tables or session tables to get to know, which session is idle for the longest time and so to kill it via STOPSESSION, but to leave out Users with a custom boolean flag like "Protected", so that nevertheless, one of these users are idle for the longest period, but my code wouldn't run STOPSESSION on these users' session.
Thanks anyway, but I would like to do this from NAV NAS, not from SQL directly, if possible, searched and googled it for a long time, so now I think I ask the forum, thank you in advance!
Best regards,
Gyula
0
Answers
-
This is, what I found from SQL side and have modified the original script, so that the session record with sleeping status and the biggest difference between login_time and last_batch, but I would like to make it much more elegant, than this:
SELECT top 1 *
FROM master..sysprocesses (NOLOCK)
WHERE spid>50
AND loginame <> 'DIR%'
AND status='sleeping'
and [program_name] = 'Microsoft Dynamics NAV Server'
order by DATEDIFF(mi,last_batch,login_time) asc
UPDATE:
Sadly, from SQL I can only query the service connections, but not the client connections running through the service.0 -
You can look into Active Session table, there is the "Login Datetime" field in there, you can use it to find and kill the oldest sessions, but apart from that I don't think you'd be able to retrieve the session's 'idle' time and find the oldest inactive sessions.Slawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;1 -
Yes, thanks, I found it as well, the idle session time was the question in my case. I could only query it from master sysobjects, but not from standard NAV system tables, but sadly, from SQL I can only query the service connections, but not the client connections running through the service.0
-
wrong postUnited Kingdom0
-
Developer101 wrote: »wrong post
Why wrong?0 -
sorry i was typing my reply which was meant for another post and i could not delete it so i edited it to wrong post.. just ignore it
United Kingdom1
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

