@@NESTLEVEL
call-stack depth
What changes
- Input
- module nesting depth
- Output or change
- int
- Return type
- int
Syntax at a glance
@@NESTLEVEL
Work example
Check nested procedure or trigger depth during a call-chain investigation.
Read in the same session and compare before and after a controlled session setting change.
Check your work Compare values at entry and return boundaries because nested calls change the level.
Open Microsoft Learn for full syntax, permissions, and details for your version.