반응형
MSSQL - 락(lock)체크 Query
exec sp_lock
dbcc inputbuffer(60)
select p.status, p.program_name, p.hostname
, p.spid, p.blocked, p.kpid, p.cpu, p.physical_io, p.waittype, p.waittime, p.lastwaittype, p.waitresource, p.dbid
, p.uid, p.memusage, p.login_time, p.last_batch
, p.ecid, p.open_tran, p.sid, p.hostprocess
, p.cmd, p.nt_domain, p.nt_username, p.net_address, p.net_library, p.loginame
, p.context_info, p.sql_handle, p.stmt_start, p.stmt_end
FROM master..sysprocesses p
where (status like 'run%' or waittime > 0 OR blocked <> 0 OR open_tran <> 0
OR EXISTS(SELECT * FROM master..sysprocesses p1 where p.spid = p1.blocked and p1.spid <> p1.blocked)
)
AND spid > 50
AND spid <> @@spid
ORDER BY CASE WHEN status like 'run%' THEN 0 ELSE 1 END
, waittime DESC, open_tran desc
반응형