Can we nest stored procedures and functions?

Posted by Peermohamedmydeen under Interview Questions on 9/15/2010 | Points: 10 | Views : 1721 | Status : [Member] | Replies : 1
In SQL Server, can we execute SP's inside the function and vice versa? If possible how many levels can we nest?


Posted by: Nishithraj on: 9/15/2010 [Member] Bronze | Points: 25

In Sql Server 2005 or 2000, You can nest stored procedures or functions up to 32 levels.(Procedures inside procedures). And this counter is stored inside a function @@NESTLEVEL.(Current level of nesting).

Further, you can call functions direcltly inside a SP. But vice versa is not possible. But some people are claiming that this is possible through xp_cmdshell. I'm not sure about this and never tried.

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Peermohamedmydeen, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response