sqlserver check running process 1

check process script 1, check which is current running:

 

use master

 

 

SELECT

spid,ER.percent_complete,

CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), '

+ CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, '

+ CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time,

CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), '

+ CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, '

+ CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go,

DATEADD(second,estimated_completion_time/1000, getdate()) as est_completion_time,

ER.command,ER.blocking_session_id, SP.DBID,LASTWAITTYPE,

DB_NAME(SP.DBID) AS DBNAME,

SUBSTRING(est.text, (ER.statement_start_offset/2)+1,

((CASE ER.statement_end_offset

WHEN -1 THEN DATALENGTH(est.text)

ELSE ER.statement_end_offset

END - ER.statement_start_offset)/2) + 1) AS QueryText,

TEXT,CPU,HOSTNAME,LOGIN_TIME,LOGINAME,

SP.status,PROGRAM_NAME,NT_DOMAIN, NT_USERNAME

FROM sysprocesses SP

INNER JOIN

sys.dm_exec_requests ER

ON SP.spid = ER.session_id

CROSS APPLY sys.dm_exec_sql_text(ER.sql_handle) est

 

kkkhh.JPG.jpg

 

You see if there happen lock , you can see them  

 

After that you may execute "kill  xxx"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值