"Level" scope in local temporary tables sql server -


i reading book mentioning

local temporary tables visible throughout level created them, across batches, , in inner levels of call stacks. if create temporary table in specific level in code , execute dynamic batch or stored procedure, inner batch can access temporary table.

and

table variables not visible across batches in same level

from other sources, understand local temporary tables visible session created , destroyed when session closes.

so "level" , "inner levels of call stacks" mean here?

picture stored procedure called a than, in turn, calls 2 stored procedures, b , c1.

each of these stored procedures creates temporary table same name, prefixed (of course) # (so, a creates #a) first action, before running further code.

you execute following code in query analyser:

create table #f (id int not null) exec go exec 

code in a can work tables #f , #a.

code in b can work tables #f, #a , #b

code in c can work tables #f, #a , #c

despite b , c being @ same "level" (they both called a), c cannot access temp table b created (it destroyed when b exited).


1

create procedure     create table #a (id int not null)     exec b     exec c 

Comments