Nesting procedures within procedures

Nesting occurs when one stored procedure or trigger calls another. The nesting level is incremented when the called procedure or trigger begins execution and is decremented when the called procedure or trigger completes execution. The nesting level is also incremented by one when a cached statement is created. Exceeding the maximum of 16 levels of nesting causes the procedure to fail. The current nesting level is stored in the @@nestlevel global variable.

You can call another procedure by name or by a variable name in place of the actual procedure name. For example:

create procedure test1 @proc_name varchar(30)
    as exec @proc_name