Check SQL Server Deadlock
Sometimes a script keeps running for a long time and can't stop, then a db blocking is occurring.
We can do below things to kill the db process which is blocking others.
- Run “sp_who2“ in db, we can get the sql process list like below pic.
Take below pic as example, we can see process 6 is blocked by process 3.
- Run below script to see the detail of the block.
SELECT TOP 10 @@SERVERNAME ,@@SERVERNAME + CHAR(10) + CHAR(13)
+ 'Wait: ' + CAST(DATEDIFF(ss, Start_Time, GETDATE()) AS VARCHAR(20)) + ' SS' + CHAR(10) + CHAR(13)
+ 'Host_name: ' + ISNULL(host_name, '') + CHAR(10) + CHAR(13)
+ 'Login_name: ' + ISNULL(b.Login_name, '') + CHAR(10) + CHAR(13)
+ 'program_name: ' + ISNULL(program_name, '') + CHAR(10) + CHAR(13)
+ 'Database: ' + ISNULL(db_name(a.database_id), '') + CHAR(10) + CHAR(13)
+ ISNULL(c.text, '') + CHAR(10) + CHAR(13)
+ 'wait_type: ' + wait_type + CHAR(10) + CHAR(13)
+ 'Session_ID: ' + CAST(a.Session_ID AS VARCHAR(10)) , GETDATE()
FROM sys.dm_exec_requests a
INNER JOIN sys.dm_exec_sessions b ON a.session_id = b.session_id CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) c
WHERE a.session_id > 50
AND DATEDIFF(ss, Start_Time, GETDATE()) BETWEEN 10 AND 200
AND wait_type NOT IN ('BROKER_RECEIVE_WAITFOR')
AND blocking_session_id > 0
ORDER BY DATEDIFF(ss, Start_Time, GETDATE()) DESC
- Run script "Kill 3' in db (3 is the db process id), and we can stop the process which blocks others.
Check SQL Server Deadlock的更多相关文章
- sql server deadlock跟踪的四种方法
最近写程序常会遇到deadlock victim,每次一脸懵逼.研究了下怎么跟踪,写下来记录下. 建测试数据 CREATE DATABASE testdb; GO USE testdb; CREATE ...
- sql server deadlock problem
https://www.red-gate.com/simple-talk/sql/learn-sql-server/how-to-track-down-deadlocks-using-sql-serv ...
- SQL CHECK sql server免费监控单实例工具
SQL Check 阅读目录 SQL Check? 主要特点 说说不足 下载地址 小结 一款实时性能监测工具 回到目录 SQL Check? 一款实时监测SQL数据库性能.实时排查的问题的免费工具. ...
- check sql server edition (version 版本)
SELECT @@VERSION refer : https://www.mssqltips.com/sqlservertip/1140/how-to-tell-what-sql-server-ver ...
- SQL Server 2012故障转移的looksalive check和is alive check
什么是looksalive check和is alive check SQL Server故障转移集群是建立在windows集群服务上的一种热备的高可用方案.在集群运行过程中,windows集群服务定 ...
- Cannot connect to (local) sql server 2008
Make following steps to solve the issue: Cannot connect to (local). ADDITIONAL INFORMATION: Login fa ...
- Create maintenance backup plan in SQL Server 2008 R2 using the wizard
You will need to identify how you want your maintenance plan to be setup. In this example the mainte ...
- SQL SERVER ENTERPRISE EDITION-CORE VS SERVER+CAL – DEMO ON DIFFERENCES
SQL SERVER ENTERPRISE EDITION-CORE VS SERVER+CAL – DEMO ON DIFFERENCES DHARMENDRA KESHARIAugust 03, ...
- sql:SQL Server metadata queries
http://www.mssqltips.com/sqlservertip/3449/making-sql-server-metadata-queries-easier-with-these-new- ...
随机推荐
- Logstash利用ruby将有用的日志放到一个ES_INDEX将无用的日志放到另一个ES_INDEX
input{ kafka { bootstrap_servers => "127.0.0.1:9092" client_id => "nginxlog&quo ...
- git生成ssh key步骤并添加到github网站
0: 查看是否已经有了ssh密钥 执行命令:cd ~/.ssh 如果没有密钥则不会有此文件夹,有则备份删除 1:使用 Git Bash生成新的ssh key ssh-keygen -t rsa -C ...
- kth min_max容斥
题解: 普通的$min-max$容斥是用来求最后出现元素的期望之类的 $kth min-max$容斥进一步解决倒数第k个出现的元素的期望 给出公式: $kthmax(S)=\sum\limits_{T ...
- 网络编程-Python高级语法-装饰器
理论:装饰器就是运行一个函数之前首先运行装饰器函数,python装饰器就是用于拓展原来函数功能的一种函数,这个函数的特殊之处在于它的返回值也是一个函数,使用python装饰器的好处就是在不用更改原函数 ...
- 20172328 2018-2019《Java软件结构与数据结构》第五周学习总结
20172328 2018-2019<Java软件结构与数据结构>第五周学习总结 概述 Generalization 本周学习了第九章:排序与查找,主要包括线性查找和二分查找算法和几种排序 ...
- 禁用JavaScript之后,你的网站表现如何?
一 最近要做一个新官网,需求评审完之后,考虑到官网都是纯静态页面,功能简单,操起vue-cli3几秒内创建好了项目脚手架,开发前,我打开了首页模板文件,看到下面这行字,有了一些思考-- <nos ...
- react学习一篇就够了
webstrom自动格式化代码 命令 js框架 MVC 安装 npm install create-react-app -g 生成项目(项目名npm发包包命名规范 /^[a-z0-9_-]$/) cr ...
- JS_高程8.BOM window对象(1)
1.全局作用域 var age = 14; window.coloer = "pink"; console.log(delete window.age);//false 使用var ...
- centos7安装python3 以及tab补全功能
1.安装python3 1.1下载python源码包 网址:https://www.python.org/downloads/release/python-362/ 下载地址:https://www. ...
- Windows系统IntelliJ IDEA安装配置
IntelliJ IDEA安装 IntelliJ IDEA,是java编程语言开发的集成环境,业界公认的最好的Java开发IDE之一.打开IDEA官方网站https://www.jetbrains.c ...