Search code examples
sql-serverpid

SQL Server SPID doesnt change for every connection


We are building an ERP system, and sometimes we need to see the SQL statement in SQL Server Profiler for debuging purposes. I can catch my ERP's queries by the SPID on Profiler. My ERP doesnt keep an open connection, it opens a connection everytime it needs it.

I have been thinking that everytime my ERP opens a connection, it should get a new SPID. How does it give the same SPID?


Solution

  • SPIDs are recycled, they are guaranteed to be unique at any one time, but if a connection drops, its SPID can be reused by a new connection.