Home Forums SQL Server 2008 SQL Server 2008 - General sql server 2000: how to limit a users session connecting to the database. RE: sql server 2000: how to limit a users session connecting to the database.

  • In SQL2008 you probably want to use sys.dm_exec_sessions and identify sessions that have been idle for the last 30 minutes:

    DECLARE @idle_timeout int = 30; -- minutes

    SELECT session_id

    ,status

    ,login_time

    ,host_name

    ,program_name

    ,host_process_id

    ,original_login_name

    FROM sys.dm_exec_sessions

    WHERE status = 'sleeping'

    AND last_request_end_time < DATEADD(minute, -1 * @idle_timeout, GETDATE())

    AND is_user_process = 1

    -- Gianluca Sartori