How to find session id and process name

minh tran 76 Reputation points
2021-12-14T15:21:36.003+00:00

Hello,
I would like to get your helps and expertise regarding finding a session id and its process name in my test database.

I am having a scenario that I would like to find the session id associated with the SQLQUERYNOTIFICATIONSERVICE running in my test database.

I googled and I found this query 



  select session_id, program_name, interface_name from sys.dm_exec_sessions where database_id = 13;

But it did not give me the SQLQUERYNOTIFICATIONSERVICE process that currently running in my database number 13.

So I would like to seek your help and expertise if you can direct me to a query that would give us the session_id, process_id and process_name of every process running in my test database number 13.

Many Thanks for the helps,

Du

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,808 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Tom Phillips 17,716 Reputation points
    2021-12-14T16:25:57.513+00:00

    SQLQUERYNOTIFICATIONSERVICE is something which runs and stop and runs and stops. You would have to run your query at the exact second it runs.

    What exactly are you trying to accomplish? Are you having a problem of some kind?

    0 comments No comments

  2. Seeya Xi-MSFT 16,446 Reputation points
    2021-12-15T06:16:31.66+00:00

    Hi @minh tran ,

    Welcome to Microsoft Q&A!
    You can try to use sp_WhoIsActive to get more information.
    https://www.sqlshack.com/monitoring-activities-using-sp_whoisactive-in-sql-server/
    http://whoisactive.com/docs/06_options/

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments