SQL Script to delete stranded activity for a specific user
Hi all
In this article I am providing a script to delete the activity table records for a specific stranded user in Dynamics GP. This will enable us not to have all the users log out of GP in order to execute these scripts. This is typically handy when we have many users signed into the system from various regions and its a tough job to have all the users sign off the system for this maintenance to be done.
Note: Its always advisable to take a back up of the DYNAMICS database before you execute this script.
![]()
DECLARE @USERID CHAR(15) DECLARE @CMPNYNAM CHAR(30) SET @USERID = 'testuser' SET @CMPNYNAM = 'Fabrikam, Inc.' /*Deleting the user record from the DEX_LOCK table*/ DELETE FROM tempdb.dbo.DEX_LOCK WHERE session_id = ( SELECT SQLSESID FROM DYNAMICS.dbo.ACTIVITY WHERE USERID = @USERID AND CMPNYNAM = RTRIM(@CMPNYNAM) ) /*Deleting the user record from the DEX_SESSION table*/ DELETE FROM tempdb.dbo.DEX_SESSION WHERE session_id = ( SELECT SQLSESID FROM DYNAMICS.dbo.ACTIVITY WHERE USERID = @USERID AND CMPNYNAM = RTRIM(@CMPNYNAM) ) /*Deleting the user record from the SY00801 table*/ DELETE FROM DYNAMICS.dbo.SY00801 WHERE USERID = @USERID AND CMPANYID = ( SELECT CMPANYID FROM DYNAMICS.dbo.SY01500 WHERE CMPNYNAM = RTRIM(@CMPNYNAM) ) /*Deleting the user record from the SY00800 table*/ DELETE FROM DYNAMICS.dbo.SY00800 WHERE USERID = @USERID AND CMPNYNAM = RTRIM(@CMPNYNAM) /*Deleting the user record from the ACTIVITY table*/ DELETE FROM DYNAMICS.dbo.ACTIVITY WHERE USERID = @USERID AND CMPNYNAM = RTRIM(@CMPNYNAM)
I hope this script above would be useful to you folks…
Until next post…
May 16, 2010
·
veeyeskay ·
5 Comments
Tags: ACTIVITY, DEX_LOCK, DEX_SESSION, DYNAMICS database, Stranded User, SY00800, SY00801, User Activity · Posted in: Dynamics, Great Plains, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, System Total Views: 1,443

Pingback: SQL Script to delete stranded activity for a specific user - DynamicAccounting.net