Showing posts with label limitation. Show all posts
Showing posts with label limitation. Show all posts

Sunday, March 11, 2012

Can stored procedure be called recursively?

Is stored procedure in mssql 2000 support recursion? Is there any limitation on the number of recursion?

what happens when you run this:


create table test (i int)
go
insert into test values(0)
go
create proc TryTest
as
declare @.i int
update test set i = i + 1
select @.i = i from test
print @.i
exec TryTest
go
exec TryTest

|||? Yes, it can. 32 levels. You can also use @.@.NESTLEVEL to determine the current level: CREATE PROCEDURE recurseASBEGIN PRINT @.@.NESTLEVEL EXEC recurseENDGO EXEC recurseGO DROP PROC recurseGO -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <nonno@.discussions.microsoft.com> wrote in message news:452f0e66-9594-4818-9d92-6de799ad0dd5@.discussions.microsoft.com...Is stored procedure in mssql 2000 support recursion? Is there any limitation on the number of recursion?|||

Does @.@.NESTLEVEL has a transactional scope?

What happens with the value of @.@.NESTLEVEL when two users (from my application) will call the same procedure, but both users have a different transaction?

Like:
UserA calls the procudure for the first time: NestLevel = 1
UserA calls the procedure again: NestLevel = 2

What will be the value of NestLevel for user B? 1 or 3?

TIA,

Isabel

|||? 1. It's the nesting level for the current scope; it has nothing to do with some other connection's scope. -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Isabel_ve@.discussions..microsoft.com> wrote in message news:dd99b941-0788-4916-a1f8-19fe6117f330@.discussions.microsoft.com... Does @.@.NESTLEVEL has a transactional scope? What happens with the value of @.@.NESTLEVEL when two users (from my application) will call the same procedure, but both users have a different transaction? Like:UserA calls the procudure for the first time: NestLevel = 1UserA calls the procedure again: NestLevel = 2 What will be the value of NestLevel for user B? 1 or 3? TIA, Isabel