Can I run multiple instances of the same stored procedure that includes temp tables in SQL Server

Viewed 556

I'm trying to execute a SQL Server stored procedure through Python Pyodbc and to get the selection results printed out into .csv files. But this procedure is currently being used in other daily tasks so I'm worried that if my executing the procedure in python will interrupt the daily scheduled job process in SQL Server Agent. In the procedure, it creates several temporary tables #temp_a, #temp_b, and #temp_c. I'm wondering if these temp tables will break the scheduled jobs that include this procedure since there might be other procedures that will be creating temp table names using the same name such as #temp_a or #temp_b. The temp tables are created inside the procedure but with no delete query written. I could have tested this myself but the database I'm working on right now is just so fragile that I was told not to create tests. Thanks!

1 Answers

Yes


The temp-Tables will be created per Session. I got the procedure execute by different Sessions on the same time there will be the same count of the temp-tables as sessions executed. This temp-tables have each a different name:

#V_...._000000003EB1

#V_...._000000003EB8

The example above are the temp-Tables created by the same Procedure executed two times by different sessions at the same time.

So your scenario couldn't happen

Related