Hi,
I have problem understanding how SQL Server SPID works when it is used in production server that has lot of stroed procedure and triggers.
I know that SPID is a Server Process ID unique to each connection made to that SQL server. I have a J2EE application server that connects to SQL server production database. The application is accessed online by lot of users in real time (lot of user sessions).
I have several stored procedure and triggers in the production database and some of these triggers are 'for update' triggers that iterates over the updated rows in the database using cursor. These cursors are using SPID for some reason.
Here is the hypothetical scenario.
SQL Server Production DB
DB Table <----- Updated through numbers of session EJBs through entity beans has 'for update' trigger on table has cursor iterating over inserted / deleted rows has code that uses @@SPID cursor closed trigger ended
In this hypothetical scenario, do we have a possibility ever that for a single trigger execution we receive different SPID? In other words do we ever have a possibility to get two different SPID values within a trigger that is executed for one update operation?
I know this may sound pretty easy to guess, but I start scratching my head when I consider that there are multiple users may be updating the same table and there may be multiple server processes in that sense executing the same trigger code at the same time. So please help me understand if my above question is valid in this condition or not.
Thanks,
Hitesh