Parallel execution of stored proce that creates temp tables
I have a stored procedure which takes input parameter as clientid and loads data for the clientid. It uses several Local temporary table (names that begin with #) in the process. Can I execute the stored procedure for different clientids at the same time parallely using a same account ?
Local Temporary tables (i.e. starting with a single `#` and not a double `##`) are known only to the session that created them. A different session_id / SPID, or even 100 different sessions, can have the same `#TempTableName` and they will all be kept separate. The separation is handled by adding a "unique" value to the end of the "real" table name. This is easy to test. Just run the following in one query tab in SSMS: CREATE TABLE #Temp1 (Col1 INT); SELECT [object_id], [name] FROM tempdb.sys.tables; Then open up a new query tab to the same Instance and run it again. You should see something like the following: object_id name ----------- ---- -1489531709 #Temp1__________________________________________________________________________000000000089 -1457531595 #Temp1__________________________________________________________________________00000000008B