What I need is a query that will use multiple threads, thereby creating multiple records in the sys.sysprocesses view.
I am working on a login alert for our systems and need some help recreating a condition causing me problems. Basically, I am working with the sys.sysprocesses system view. This gives back one record per thread. So this means that 99.99% of the time (or at least that's how it seems to me), it will return 1 and only 1 record per SPID. However, sometimes it will return more than 1 record per SPID, all with a different KPID. I have come to understand that the KPID is the thread number. I need some code that will create multiple records in the sysprocesses view while it is running (and it has to run long enough so that I can actually catch it).
All of the records where there is only 1 record per SPID seem to have a KPID of 0. I want to find out if there is always at least one record per SPID with a KPID of 0 or if when there are multiple threads running, the KPID of 0 may no longer exist. Sometimes (or maybe all the time?) when there are multiple records per SPID in this table, some of the records will not contain all the data I need for my login audit (ie. loginame is blank). So if I can find a query which creates multiple threads, I think it should also make multiple records in the sysprocesses view and I will be able to test its behavior and see what is going on with this missing loginame.
Thanks in advanced for your help!