• 查看某个数据库的表对应的锁死进程


    SELECT
        SPID                = er.session_id 
        ,'总花费时间ms'=er.total_elapsed_time/1000
        ,'完成百分比'=er.percent_complete
        ,'状态'              = 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 
        ,'开始时间'          = 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  in (
    
    select a.request_session_id  from sys.dm_tran_locks a 
    left join sysobjects b on a.resource_associated_entity_id = b.id 
    where a.resource_type='OBJECT'
    and    db_Name(a.resource_database_id) = '数据库名字' 
    and b.name='表名字'
    )
  • 相关阅读:
    go多种uuid生成方式
    go访问mysql基本语法
    go实现分布式唯一ID-snowflake(雪花算法)
    指定时间生成cron表达式
    zookeeper注册与发现
    短地址服务(二)
    java-redis
    短地址服务(一)
    cron表达式详解
    以后本blog所有内容全部转移,并在自建blog更新
  • 原文地址:https://www.cnblogs.com/panjinzhao/p/13517385.html
Copyright © 2020-2023  润新知