RS First Dynamics NAV Blog


...from NAV 3.60 to NAV 2013
Archivio Posts
Anno 2015

Anno 2014

Anno 2013

Anno 2012

Anno 2011

Anno 2010

Anno 2009

Anno 2008

Anno 2007

SQL KILL INACTIVE NAV SESSIONS

// KILL SQL INACTIVE SESSIONS FOR NAV APPLICATIONS
// ONLY FOR SLEEPING SESSIONS

a very Simple SQL Stored Procedure to 'kill' sql inactive sessions
idle (sleeping) for 10 minutes related to "Nav Client" applications

 *** it's necessary to identify correct "application name" ***
*** ex: program_name LIKE N'%NAV client% *** or %NAV Web%


Stored Procedure Script

DECLARE @v_spid INT
DECLARE c_Users CURSOR
   FAST_FORWARD FOR
   SELECT SPID
   FROM master..sysprocesses (NOLOCK)
   WHERE spid>50
   AND loginame <> 'DIR%'
   AND program_name LIKE N'%NAV client%'
   AND status='sleeping'
   AND DATEDIFF(mi,last_batch,GETDATE())>=10
   AND spid <> @@spid

OPEN c_Users
FETCH NEXT FROM c_Users INTO @v_spid
WHILE (@@FETCH_STATUS=0)
BEGIN
  PRINT 'Killing '+ CONVERT(VARCHAR,@v_spid)+'...'
  EXEC('KILL '+ @v_spid)
  FETCH NEXT FROM c_Users INTO @v_spid
END

CLOSE c_Users
DEALLOCATE c_Users

Categoria: Dynamics NAV ALL
sabato, 12 lug 2014 Ore. 20.24
Statistiche
  • Views Home Page: 468.934
  • Views Posts: 885.814
  • Views Gallerie: 0
  • n° Posts: 343
  • n° Commenti: 0
Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003