A SPID in SQL Server is a Server Process ID. These process ID’s are essentially sessions in SQL Server. Everytime an application connects to SQL Server, a new connection (or SPID) is created. This connection has a defined scope and memory space and cannot interact with other SPIDs. The term SPID is synonymous with Connection, or Session
In order to view all the connections in SQL Server execute the following query.
SELECT *
FROM sys.dm_exec_sessions
To know which sessions are running currently, run the following command:
SELECT @@SPID
GO
In our case, we got SPID 105, which means the session that is running this command has ID of 105.
Let us run a simple SELECT statement in session with SPID 105 run the following command.
DBCC INPUTBUFFER(105)
GO