I have a SQL stored proc which is supposed to be executed by multiple users. Every user will execute this proc on the same server and same database. During the execution, it will create global temp tables and drop them at the end (for example, ##temp_1
, ##temp_2
, etc.). When the proc creates the global temp tables, it uses the following code:
IF OBJECT_ID('tempDB..##temp_1') IS NOT NULL
DROP TABLE ##temp_1
So my question is, when User A
created ##temp_1
and ##temp_2
, User B
starts on another machine and start to create his ##temp_1
. According to the above code, ##temp_1
will be removed from the database if exists. Will this operation affects User A
? If the users are affecting each other, is there a way to avoid it?
Many thanks.