Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get the client process ID of an application that runs on SQL server?

For my VFP application, i have a program to check currently who is accessing the server (by using sp_who2), also another progam to check who is currently locking which table.

But i wish to know which options my users is accessing at the moment. Am thinking if i can write a SP to get the current connected process ID for a specific client, and insert to a table(ActLog) in SQL with the program name pass into this table during users load the program. And delete that particular record when user unload the program.

Then from the ActLog, i can know who is currently accessing to which program. At the moment, i wish to know if i able to get the client process ID?

rgds/Andrea

like image 670
Andrea.Ko Avatar asked Jun 02 '10 01:06

Andrea.Ko


People also ask

What is client process ID in SQL Profiler?

ClientProcessID. The ID assigned by the host computer to the process where the client application is running. This data column is populated if the client process ID is provided by the client.

What is process ID in SQL Server?

Once we connect to a SQL Server instance, it assigns a unique identification number to each connection. It is the Server Process ID and commonly known as SPID. SPID 1 to 50 is reserved for SQL Server internal processes, and the user process starts from SPID 51.

How can I get the session ID of the current user process in SQL?

@@SPID returns the session ID of the current user process of the SQL connection. We get smallint value as a session id from this function. SPID is a key value that administrators can use to track the activities of the users sessions in the server.


1 Answers

host_process_id in sys.dm_exec_sessions:

Process ID of the client program that initiated the session

like image 83
Remus Rusanu Avatar answered Nov 17 '22 10:11

Remus Rusanu