How to remove all the inactive sessions from the DEX_SESSION table in the TempDB database when you use Microsoft Dynamics GP together with Microsoft SQL Server

This article describes how to remove all the inactive sessions from the DEX_SESSION table in the TempDB database when you use Microsoft Dynamics GP together with Microsoft SQL Server.

Applies to:   Microsoft Dynamics GP
Original KB number:   864413

Introduction

To remove the inactive sessions, you must first find the inactive sessions. After you find the inactive sessions, you must delete them. To do it, use the appropriate method.

Microsoft SQL Server

  1. Start Microsoft SQL Server Management Studio.

  2. Find the inactive sessions. To do it, paste the following statement in the New Query window, and then run the statement against the DEX_SESSION table.

    SELECT * from TempDB..DEX_SESSION where Session_ID not in (SELECT SQLSESID from DYNAMICS..ACTIVITY)
    
  3. Delete the inactive sessions in the DEX_SESSION table. To do it, paste the following statement in the New Query window, and then run the statement against the DEX_SESSION table.

    DELETE TempDB..DEX_SESSION where Session_ID not in (SELECT SQLSESID from DYNAMICS..ACTIVITY
    

For more information about how to remove inactive sessions from the DEX_LOCK table, see How to remove all the inactive sessions from the DEX_LOCK table in the TempDB database when you use Microsoft Dynamics GP together with Microsoft SQL Server.