Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize

@@NESTLEVEL

SQL Server 2000

Returns the nesting level of the current stored procedure execution (initially 0).

Syntax

@@NESTLEVEL

Return Types

integer

Remarks

Each time a stored procedure calls another stored procedure, the nesting level is incremented. When the maximum of 32 is exceeded, the transaction is terminated.

Examples

This example creates two procedures: one that calls the other, and one that displays the @@NESTLEVEL setting of each.

CREATE PROCEDURE innerproc as 
select @@NESTLEVEL AS 'Inner Level'
GO

CREATE PROCEDURE outerproc as 
select @@NESTLEVEL AS 'Outer Level'
EXEC innerproc
GO

EXECUTE outerproc
GO

Here is the result set:

Outer Level 
----------------- 
1                 

Inner Level 
----------------- 
2                 

See Also

Configuration Functions

Creating a Stored Procedure

@@TRANCOUNT

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft