Sqlserver-查询和kill杀死正在运行的事务
1.查询正在运行的事务
SELECT session_id, task_state, pending_io_count, context_switches_count
FROM sys.dm_os_tasks
WHERE session_id > 50
ORDER BY task_state asc
2.杀死运行的事务Kill
kill 303
SELECT DISTINCT
'kill ' + CONVERT ( VARCHAR, request_session_id ),
OBJECT_NAME( resource_associated_entity_id ) tableName
FROM
sys.dm_tran_locks
WHERE
resource_type = 'OBJECT'