zoukankan      html  css  js  c++  java
  • SQLServer查询进程与死锁语句

    查询当前进程信息:

    SELECT
    SPID = er.session_id
    ,Status = ses.status
    ,[Login] = ses.login_name
    ,Host = ses.host_name
    ,BlkBy = er.blocking_session_id
    ,DBName = DB_Name(er.database_id)
    ,CommandType = er.command
    ,SQLStatement = st.text
    ,ObjectName = OBJECT_NAME(st.objectid)
    ,ElapsedMS = er.total_elapsed_time
    ,CPUTime = er.cpu_time
    ,IOReads = er.logical_reads + er.reads
    ,IOWrites = er.writes
    ,LastWaitType = er.last_wait_type
    ,StartTime = er.start_time
    ,Protocol = con.net_transport
    ,ConnectionWrites = con.num_writes
    ,ConnectionReads = con.num_reads
    ,ClientAddress = con.client_net_address
    ,Authentication = con.auth_scheme
    FROM sys.dm_exec_requests er
    OUTER APPLY sys.dm_exec_sql_text(er.sql_handle) st
    LEFT JOIN sys.dm_exec_sessions ses
    ON ses.session_id = er.session_id
    LEFT JOIN sys.dm_exec_connections con
    ON con.session_id = ses.session_id
    WHERE er.session_id > 50
    ORDER BY
    er.blocking_session_id DESC
    ,er.session_id

    查询死锁语句:

    select
    request_session_id spid,
    OBJECT_NAME(resource_associated_entity_id) tableName
    from sys.dm_tran_locks
    where resource_type='OBJECT'


    删除死锁:
    kill 112
    go
    kill 135

  • 相关阅读:
    C#创建ActiveX
    easy-ui 中的事件触发 (tree)
    程序目录
    微信公众平台开发
    Redis分片机制
    Redis主从切换
    Redis主从复制
    Redis持久化机制
    Redis缓存击穿、缓存穿透、缓存雪崩
    Redis与数据库数据一致性
  • 原文地址:https://www.cnblogs.com/thatzzz0414/p/15013864.html
Copyright © 2011-2022 走看看