It is easy to find these ids in SQL server and what is their importance and role. I was asked a question based on these different ids in an interview so I collected more info on the same and now publishing for our DBA friends.
How to find Spid, Kpid, Ecid, dbid, and uid in SQL Server.
Go to SSMS and open a new session
Select * from sys.sysprocesses
Result would be like this:
Sys.sysprocesses contains information about processes that are running on an instance of SQL Server. These processes can be client processes or system processes.
spid: SQL Server session ID.
kpid: Windows thread ID.
dbid: ID of the database currently being used by the process.
Uid: ID of the user that executed the command. Overflows or returns NULL if the number of users and roles exceeds 32,767.
ecid: Execution context ID used to uniquely identify the subthreads operating on behalf of a single process.
If you feel that this information is useful please leave a comment or like which will encourage me to write other stuff in future.