SQL SERVER – Difference Between spid, kpid and ecid in sysprocesses

Question: What is the difference between spid, kpid and ecid in sysprocesses?

Answer: When I received this question, I actually went and checked SQLAuthority.com blog as I thought I have blogged about it, but the reality was that I had not blogged about it before. So here it goes.

Spid, kpid, and ecid for SQL Server sysprocesses.

First, let us understand where we can find about three columns. We can find above three columns in sys.sysprocesses table. You can see that by running the following script:

SELECT spid,kpid,ecid
FROM sys.sysprocesses

Now let us understand what each of the columns means.

Spid
Every process in SQL Server is running under a server process. They are referred to as session IDs. Each of these session processes has a unique ID known as SPID.

Kpid
SPIDs are in the context of SQL Server. The same processes run in Operating System as a Kernel Process. Each Kernal Process has its own ID which is known as KPID.

Ecid
If a process is multi-threaded, all the sub-thread have the same parent Server Process ID (SPID). Each sub-thread has its own unique identifier known as ECID.

Well, that’s it. I hope now it is clear now what each of the columns means.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.

SQL DMV, SQL Scripts, SQL Server, System Object
Previous Post
SQL SERVER – How to Build Three Part Name from Object_ID – Part 2?
Next Post
SQL SERVER – How to Clear Plan Cache with Database Scoped Configuration?

Related Posts

4 Comments. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.