Article ID: 131913
Article Last Modified on 2/22/2005
--**** Top level nesting level is 0
1> select "Nesting level is " + str (@@nestlevel)
2> go
---------------------------
Nesting level is 0
--**** Try nesting level in a sproc.
1> create proc #nestlevel as
2> select "Nesting level is " + str (@@nestlevel)
3> go
1> #nestlevel
2> go
---------------------------
Nesting level is 1
--**** Here is an interesting one. If we use the EXEC ('string')
--**** syntax, it introduces another nesting level. That means that
--**** any local temporary tables that we defined inside
--**** EXEC ('string') will be dropped when the EXEC is completed.
1> exec ('#nestlevel')
2> go
---------------------------
Nesting level is 2
--**** Note that EXEC proc syntax doesn't result in a new level.
1> exec #nestlevel
2> go
---------------------------
Nesting level is 1
Additional query words: sql6 exec temp tables scope
Keywords: kbinfo kbother KB131913