I'm creating SQL mechanism (in MSSQL 2005) which allows only one user at time set the field in certain table. If this field is set, no one else can clear it (set to NULL). If not, this field is set to something unique for the user's session
. As a good candidate master.dbo.sysprocesses.sid
looks for me, but I'm not sure with it.
I need to ensure when the user's client application (which will use this mechanism) crashes, the field will be cleared so another users will be able to use it. I'm thinking about some clearing job, which will check if the user's session which set this field is active yet and if not, then clear it (of course only when the field is not NULL).
Is there a unique column in master.dbo.sysprocesses for each user session without reusing the same value later on ?
Thanks a lot