Home All Groups Group Topic Archive Search About

Newbie question Local Temp Tables vs Global Temp Tables

Author
24 Mar 2006 5:32 PM
Stephen K. Miyasato
I'm trying to find the distinction between Local temp tables vs. Global Temp
Tables.

Seem that Global temp tables have greater persistence when using a stored
procedure with a returning select statement.

Question: Are any of the #tempLocalTable or ##tempGlobalTable accessible
from other network users? i.e. can user using the same stored procedures at
the same time overwrite either of these tables?

Thanks for the answers.

Stephen K. Miyasato

Author
24 Mar 2006 7:14 PM
Tibor Karaszi
Local temp tables are private to the connection created the tamp table. Global temp tables are not,
they are ... global.

Show quote
"Stephen K. Miyasato" <miya***@flex.com> wrote in message
news:u78Xuj2TGHA.1576@tk2msftngp13.phx.gbl...
> I'm trying to find the distinction between Local temp tables vs. Global Temp Tables.
>
> Seem that Global temp tables have greater persistence when using a stored procedure with a
> returning select statement.
>
> Question: Are any of the #tempLocalTable or ##tempGlobalTable accessible from other network users?
> i.e. can user using the same stored procedures at the same time overwrite either of these tables?
>
> Thanks for the answers.
>
> Stephen K. Miyasato
>
>
Author
24 Mar 2006 7:51 PM
JT
Yes, global temp tables have greater persistence, but I've never found an
actual need to retain a temporary table beyond the context of the procedure
that created it. Have you?

Show quote
"Stephen K. Miyasato" <miya***@flex.com> wrote in message
news:u78Xuj2TGHA.1576@tk2msftngp13.phx.gbl...
> I'm trying to find the distinction between Local temp tables vs. Global
> Temp Tables.
>
> Seem that Global temp tables have greater persistence when using a stored
> procedure with a returning select statement.
>
> Question: Are any of the #tempLocalTable or ##tempGlobalTable accessible
> from other network users? i.e. can user using the same stored procedures
> at the same time overwrite either of these tables?
>
> Thanks for the answers.
>
> Stephen K. Miyasato
>
>
Author
24 Mar 2006 9:33 PM
Stephen K. Miyasato
I guess when I did do a stored procedure, I found that the #tempLocalTable
was not available, so I thought using he global tables would have been a
solution. Perhaps I'm doing it wrong. I ended up using regular tables but
when the stored procedure were used on different stations simultaneously, I
would get results not related to the patient.

Thanks,

Stephen K. Miyasato

Show quote
"JT" <some***@microsoft.com> wrote in message
news:ugUTNx3TGHA.1868@TK2MSFTNGP09.phx.gbl...
> Yes, global temp tables have greater persistence, but I've never found an
> actual need to retain a temporary table beyond the context of the
> procedure that created it. Have you?
>
> "Stephen K. Miyasato" <miya***@flex.com> wrote in message
> news:u78Xuj2TGHA.1576@tk2msftngp13.phx.gbl...
>> I'm trying to find the distinction between Local temp tables vs. Global
>> Temp Tables.
>>
>> Seem that Global temp tables have greater persistence when using a stored
>> procedure with a returning select statement.
>>
>> Question: Are any of the #tempLocalTable or ##tempGlobalTable accessible
>> from other network users? i.e. can user using the same stored procedures
>> at the same time overwrite either of these tables?
>>
>> Thanks for the answers.
>>
>> Stephen K. Miyasato
>>
>>
>
>
Author
25 Mar 2006 12:53 PM
Dan Guzman
Global and permanent tables are visible to all connections so you need to
account for multi-user environments when using these for transitory data.
It's best to stick with a local temp table or table variable in those cases.

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Stephen K. Miyasato" <miya***@flex.com> wrote in message
news:OiWhVq4TGHA.1160@TK2MSFTNGP09.phx.gbl...
>I guess when I did do a stored procedure, I found that the #tempLocalTable
>was not available, so I thought using he global tables would have been a
>solution. Perhaps I'm doing it wrong. I ended up using regular tables but
>when the stored procedure were used on different stations simultaneously, I
>would get results not related to the patient.
>
> Thanks,
>
> Stephen K. Miyasato
>
> "JT" <some***@microsoft.com> wrote in message
> news:ugUTNx3TGHA.1868@TK2MSFTNGP09.phx.gbl...
>> Yes, global temp tables have greater persistence, but I've never found an
>> actual need to retain a temporary table beyond the context of the
>> procedure that created it. Have you?
>>
>> "Stephen K. Miyasato" <miya***@flex.com> wrote in message
>> news:u78Xuj2TGHA.1576@tk2msftngp13.phx.gbl...
>>> I'm trying to find the distinction between Local temp tables vs. Global
>>> Temp Tables.
>>>
>>> Seem that Global temp tables have greater persistence when using a
>>> stored procedure with a returning select statement.
>>>
>>> Question: Are any of the #tempLocalTable or ##tempGlobalTable accessible
>>> from other network users? i.e. can user using the same stored procedures
>>> at the same time overwrite either of these tables?
>>>
>>> Thanks for the answers.
>>>
>>> Stephen K. Miyasato
>>>
>>>
>>
>>
>
>

AddThis Social Bookmark Button