Azure sql database check current active running session and query

sakuraime 2,316 Reputation points
2021-04-09T10:18:23.723+00:00

I would like to have a query to check in Azure sql database, where I can see the current running active query from which spid , user ,host,ip program . Any one has the idea ?

Azure SQL Database
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anurag Sharma 17,571 Reputation points
    2021-04-09T12:36:49.817+00:00

    Hi @sakuraime , welcome to Microsoft QnA forum.

    You can run below query to get all the required information:

    select  
        r.session_id,  
        s.login_name,  
        c.client_net_address,  
        s.host_name,  
        s.program_name,  
        st.text, s.status  
    from sys.dm_exec_requests r  
    inner join sys.dm_exec_sessions s  
    on r.session_id = s.session_id  
    left join sys.dm_exec_connections c  
    on r.session_id = c.session_id  
    outer apply sys.dm_exec_sql_text(r.sql_handle) st  
    where client_net_address is not null and text is not null and s.status = 'running'  
    

    Reference Article: Get username and/or IP address responsible for a query

    Please let us know if this helps.

    ----------

    If answer helps, please mark it as 'Accept Answer'

    1 person found this answer helpful.

  2. Dan Guzman 9,206 Reputation points
    2021-04-09T15:36:14.403+00:00

    Consider using sp_whoisactive. This will show active queries along with resource utilization.

    0 comments No comments