I'd like to get active user session count before rebooting instance, exclude any background sessions.
Just thinking to use following query but I'm not sure how to exclude select session for tempdb by SQL Server.
SELECT COUNT(*) FROM sys.dm_exec_requests WHERE session_id in (select session_id from sys.dm_exec_sessions where status = 'running')
Any advice would be appreciated again.