Before I get any warlike cursor beating, let me say that I'm trying to use nested cursors to do something that I only need to do once, but if I run the online stored procedure once for each user and agency, I have done it a few hundred times.
I thought that the nested cursor in this case would save me some work, however, when I ran this script, it only goes through the outer cursor once, while the inner work is great for this run. In the test case, the external cursor set consists of two lines, and the internal one is about fifty. It goes through the first line of the outer cursor and all fifty inner ones, but then it is done.
As you can see, I save the result of the external selection ("@@ fetch_status"), so it does not interfere with the internal cursor.
I do not see what the problem is (obviously). Can anyone see what I can not?
declare @fetch_user int declare @fetch_agency int declare user_cursor cursor for select upn from
source share