Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 concurrency when executing stored procedure

Author  Topic 

Oliver wang
Yak Posting Veteran

50 Posts

Posted - 2010-12-24 : 03:35:32
Hi Everyone,

I got a question here, please think of the following scenario:
I create a temp table #t in a stored procedure(SP), Suppose now there are 3 users executing the SP simultaneously, and my concern is whether there will be 3 temp tables which have the same table name '#t' in temp database. if there only can be one temp table at a time, does that mean the SP will have to be executed in a sequential manner? Thanks for your guidence.

regards,

Oliver

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-24 : 03:44:07
There will be three temp tables.

The temp tables will be created in temp database and sql server will assign some suffix to the name to make it unique.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-12-24 : 05:05:56
To have a single table that will cause the problem you anticipate you have to use a Global Temp Table called ##t

So, as pk_bohra says, you will be fine with a #t temp table
Go to Top of Page

Oliver wang
Yak Posting Veteran

50 Posts

Posted - 2010-12-29 : 02:26:28
Thank you very much for your detailed explanation.
Go to Top of Page
   

- Advertisement -