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 2000 Forums
 SQL Server Development (2000)
 Temporary Tables in SQL2K

Author  Topic 

skillile
Posting Yak Master

208 Posts

Posted - 2002-05-17 : 13:42:56
When creating a local temp table ie:

create table #temp (x)

Is this per session or SPID based. In other words if 100 users
hit my server and run this sproc will it fail because the table exists. (I don't think it will, I think it is session based)

My impression that create table ##temp is global and this would fail
for multiple users.

Any shed light on this issue would be appreciated.

Thanks


slow down to move faster...

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-05-17 : 14:00:17
quote:

If you create a local temporary table named #employees, you are the only person who can work with the table, and it is deleted when you disconnect.
-sql7 bol



sounds like you've got it right . . . except . . . The SPID is a unique integer assigned to each user connection when the connection is made.

so the answer to "Is this per session or SPID based." would be 'yes'

<O>
Go to Top of Page

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-05-17 : 14:01:31
BOL says
quote:
You can create local and global temporary tables. Local temporary tables are visible only in the current session; global temporary tables are visible to all sessions.

Prefix local temporary table names with single number sign (#table_name), and prefix global temporary table names with a double number sign (##table_name).



Hope that helps..



Ack Sniped... I think page47 types faster than me


Edited by - M.E. on 05/17/2002 14:02:15
Go to Top of Page
   

- Advertisement -