Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 779
The real napster Avatar asked May 13 '09 11:05

The real napster


People also ask

What are the two main types of temporary tables?

There are 2 types of Temporary Tables: Local Temporary Table, and Global Temporary Table.

What are the 2 types of temporary tables in SQL Server?

SQL Server provides two types of temporary tables according to their scope: Local Temporary Table. Global Temporary Table.

What is the use of temporary tables?

Temporary Tables are a great feature that lets you store and process intermediate results by using the same selection, update, and join capabilities that you can use with typical SQL Server tables. The temporary tables could be very useful in some cases to keep temporary data.


1 Answers

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

like image 55
mmx Avatar answered Oct 05 '22 08:10

mmx