tags:

views:

224

answers:

3

Can a KPID (as select kpid from master..sysprocesses) be assumed to be globally and always unique? (I've found that for my small sample set KPID(n+1) ~= KPID(n) + 65536 (2^16) but I want to know if I can assume, previous db connections kpid is unique, even if it's previous loginame and spid match a new loginame and spid)

Cheers.

BLT.

(Already answered) *B) Loginame: how can I get the loginame from a current spid? *loginame isn't a column in sysprocesses, and I can't find any table other than sysobjects that has a column with loginame, and I can't programatically get the loginame out of sp_who. Maybe the sql used to generate sp_who would help..*

A: 

Answer to part B)

master..syslogins.suid <-> master..sysprocesses.suid

As in, you can get the name of a connection a la sp_who by going

select p.spid, l.name, p.loggedindatetime 
from master..syslogins l, master..sysprocesses p
where l.suid = p.suid

By answering my own questions I'm helping to grow stackoverflow ^_^

glasnt
+1  A: 

Based on these docs KPID is unique within the machine. It may be unique within a cluster but this seems unlikely since it refers to an identifier within the underlying operating system.

Since it is only a 32bit value there is no way it can be globally unique.

Based on this glossary

Kernel Process ID Version: 11.0 and later
An Adaptive Server process identifier that remains unique over long periods of time.

The 'uniqueness' of the value has some sort of timeframe but it is not guaranteed.

ShuggyCoUk
Thanks for that, Shuggy. That's what all I wanted to know :)
glasnt
A: 

You can translate a suid to a login name by using the SUSER_NAME() function e.g.

SELECT spid,
       SUSER_NAME(suid)      AS login_name
  FROM master..sysprocesses
 ORDER
    BY login_name ASC
Paul Harrington