The statement
CREATE TABLE #WorkTable ( column1Name column1Type, column2Name column2Type )
creates a table in tempdb.
If two different users run this statement, each user will have a separate instance of the table.
However, it is not clear what happens when a trusted user is used to connect to the database from an application server that can service multiple requests.
 
 
A different approach is to use table variables.
Declare @WorkTable Table ( column1Name column1Type, column2Name column2Type )
 
insert into @WorkTable … select ….
 
Process the table.
 
The table variable is automatically deleted when processing is done.
Advertisements