I've just begun to work in 2005 and am trying to run a cursor without any modification, which has proven to work in SQL 2000 and it's not looping.
the cursor has a few declared variables, running a select statement and assigning the returned value to the variables, then executing a sp using the variables as input. It is really written out textbook, for example:
declare
@.var1 int
declare cuMyCursor
Cursor For
(Select etc...)
Open cuMyCursor
Fetch Next from cuMyCursor
into @.Var1
while @.@.fetch_status = 0
begin
execute myStoredProc
@.var1
Fetch next from cuMyCursor
into @.Var1
end
close cuMyCusor
deallocate cuMyCursor
1 record affected
It will only execute the sp once and is not looping the cursor. I've checked the source data from the select statement and there are 600+ records to loop through before fetch next will not return a record. I literally ran this on a SQL2000 db with no problem, when i copy and paste it to run it in the SQL2005 db it will not loop.
Any insight would be helpful.
Thanks,
j.r.
J.R.
No comments:
Post a Comment