sql-serverstored-procedures

Temporary tables in stored procedures


I have been wondering about temp tables in sp's and how all that can effect concurrency. SP made on a MSSQL 08 server.

If I have a SP where I create a temp table and drop it again like this:

BEGIN

CREATE TABLE #MyTempTable
(
   someField int,
   someFieldMore nvarchar(50)
)

... Use of temp table here
... And then..

DROP TABLE #MyTempTable

END

This SP will be called very very often, so my question is can there ever occur concurrency issues here?


Solution

  • Nope. Independent instances of the temporary table will be created per each connection.