---------------------------------进程情况1-----------------------
--得到SPID
if object_id('tempdb..#info') is not null drop table #info
select distinct spid
,hostname
,db_name(dbid) as dbname
,net_address,loginame,rtrim(program_name) program_name
,cmd
,case blocked when 0 then '正常' else '被'+rtrim(blocked)+'号进程堵塞' end as blocked
,cast(null as varchar(8000)) as sql
into #info
from master..sysprocesses
where hostname<>'' if object_id('tempdb..#link_info') is not null drop table #link_info
create table #link_info(EventType varchar(100) null,Parameters varchar(10) null,EventInfo varchar(8000) null )
--取执行语句
declare @spid int
declare link_cursor cursor local for select spid from #info
open link_cursor
fetch next from link_cursor into @spid
while @@fetch_status = 0
begin
truncate table #link_info
insert into #link_info
exec('dbcc inputbuffer('+@spid+')')
update #info set sql=(select top 1 eventinfo from #link_info) where spid=@spid
IF @@error <> 0
BEGIN
close link_cursor
deallocate link_cursor
ROLLBACK
RAISERROR 20001 '取执行语句失败'
RETURN
END
fetch next from link_cursor into @spid
END
close link_cursor
deallocate link_cursor
--查询结果
select * from #info
-------------------------------进程情况---------------------- 也可以用下面语句查看SPID的SQL语句
select p.spid,t.text
from sys.sysprocesses p CROSS APPLY sys.dm_exec_sql_text( p.sql_handle ) t where p.spid in (59)

sql 2008查看进程情况和对应语句,检查死锁进程的更多相关文章

  1. SQL Server 查看CPU情况

    --CPU相关视图 SELECT * FROM sys.dm_os_sys_info SELECT * FROM sys.dm_exec_sessions SELECT * FROM sys.sysp ...

  2. SQL 2008执行语句遇到内存不足(1)——error 701

    原文:SQL 2008执行语句遇到内存不足(1)--error 701 转自:http://blogs.msdn.com/b/apgcdsd/archive/2011/01/17/sql-2008-e ...

  3. sql 2008常用语法语句收集

    EXEC sp_dropuser 'test' : 从当前数据库删除用户 test EXEC sp_droplogin 'test' : 从 SQL Server 中删除登录 test select ...

  4. sql server 查看表的死锁和Kill 死锁进程

    查询出来 select        request_session_id spid,       OBJECT_NAME(resource_associated_entity_id) tableNa ...

  5. Linux查看端口、进程情况及kill进程

    看端口: ps -aux | grep tomcat 发现并没有8080端口的Tomcat进程. 使用命令:netstat –apn 查看所有的进程和端口使用情况.发现下面的进程列表,其中最后一栏是P ...

  6. 利用 SQL Monitor 查看语句运行状态步骤

    利用 SQL Monitor 查看语句运行状态步骤 1.确定语句被 SQL Monitor 监控 SQL> SELECT * FROM GV$SQL_MONITOR WHERE sql_id=' ...

  7. Sql server 查看锁和Kill 死锁进程

    死锁的概念 死锁就是两个或多个会话(SPID)相互请求对方持有的锁资源,导致循环等待的情况.下面两种方法都是用来粗暴的解决死锁的. # 已知阻塞进程ID KILL ID SELECT blocking ...

  8. SQLServer 2008中SQL增强之三 Merge(在一条语句中使用

    SQLServer 2008中SQL增强之三 Merge(在一条语句中使用Insert,Update,Delete)   SQL Server 2008提供了一个增强的SQL命令Merge,用法参看M ...

  9. 监控SQL Server正在执行的SQL语句和死锁情况

    原文:监控SQL Server正在执行的SQL语句和死锁情况 SELECT [Individual Query] = SUBSTRING(qt.TEXT, er.statement_start_off ...

随机推荐

  1. linux常用命令之文档

     不常用,经常就会遗忘,mygod,不用则退化... 目录管理命令 ls:列出指定目录下的内容格式:ls [OPTION]... [FILE]... -a:显示所有文件包括隐藏文件 -A:显示除.和. ...

  2. JavaScript GetAbsoultURl

    var img = document.createElement('A');     img.src = "/img/weixin.jpg";  // 设置相对路径给Image,  ...

  3. spring的4种事务特性,4种隔离级别,7种传播行为

    spring事务: 什么是事务: 事务逻辑上的一组操作,组成这组操作的各个逻辑单元,要么一起成功,要么一起失败. 事务特性(4种): 原子性 (atomicity):强调事务的不可分割. 一致性 (c ...

  4. 解决Linux下Svn检出Windows SVN服务器上项目SSL handshake failed: SSL error: Key usage violation in certificate has been detected.

    在Linux上检出windows SVN服务器上项目时出现了SSL handshake failed: SSL error: Key usage violation in certificate ha ...

  5. [暑假集训Day3T1]小木棍

    经典搜索题. 考虑以下9种优化 1)按木棍长度排序,使得较大长度的木棍被较早的选出. 2)只找能够整除的木棍长度,因为不能被sum整除一定不会出整数根,自然也就不是最优解. 3)枚举木棍长度时只需从最 ...

  6. seaborn教程3——数据集的分布可视化

    原文转载:https://segmentfault.com/a/1190000015006667 Seaborn学习大纲 seaborn的学习内容主要包含以下几个部分: 风格管理 绘图风格设置 颜色风 ...

  7. 使用Anaconda3安装tensorflow,opencv,使其可以在spyder中运行

    使用Anaconda5.0.0 1.首选无论你是在cmd键入python,还是在Anaconda Prompt键入python,显示的都是Python3.6.然而在Spyder(tensorflow) ...

  8. C#split的使用方式

    一,在msdn中我们能看到一下几种使用 二,我们先看看经常使用的, 我们先定义一个数组 string test = "1,2,,3,4,5,6,7"; 第一种,结果大家都熟悉,就不 ...

  9. linux学习-系统监控工具

    系统监控工具 come from:https://blog.csdn.net/free050463/article/details/82842273top.free.vmstat.iostat.pma ...

  10. 330-支持PXIE带FMC接口的Xilinx FPGA XC7K325T PCIeX8 接口卡平台

    支持PXIE带FMC接口的Xilinx FPGA XC7K325T PCIeX8 接口卡平台 一.板卡概述     本板卡基于Xilinx公司的FPGAXC7K325T-2FFG900 芯片,pin_ ...