How to kill all inactive sessions from a specific user in SQL Server
The SQL statement below will kill all sessions from a specific user that were not active in the last hour.
Of course, change 'my_user' with your preferred user ID. If you want, you can also uncomment the 'program_name' filter if you want to filter on program name.
DECLARE @sql NVARCHAR(MAX) = N'';
SELECT @sql += N'KILL ' + CONVERT(VARCHAR(11), session_id) + N';'
FROM sys.dm_exec_sessions
--WHERE [program_name] = N'program_name'
where login_name = N'my_user'
AND last_request_end_time < DATEADD(HOUR, -1, SYSDATETIME());
select @sql;
ExEC sys.sp_executesql @sql;