SQL Stored Procedure

Posted by Nathan on Stack Overflow See other posts from Stack Overflow or by Nathan
Published on 2010-05-18T20:34:28Z Indexed on 2010/05/18 20:40 UTC
Read the original article Hit count: 218

Filed under:
|
|

I am trying to run a stored procedure with a while loop in it using Aqua Data Studio 6.5 and as soon as the SP starts Aqua Data starts consuming an increasing amount of my CPU's memory which makes absolutely no sense to me because everything should be off on the Sybase server I am working with. I have commented out and tested every piece of the SP and narrowed the issue down to the while loop. Can anyone explain to me what is going on?

create procedure sp_check_stuff as
begin

declare
    @counter numeric (9),
    @max_id numeric (9),
    @exists numeric (1),
    @rows numeric (1)

select @max_id = max(id) 
    from my_table      

set @counter = 0
set @exists = 0
set @rows = 0

while @count <= @max_id
    begin

     //More logic which doesn't affect memory usage based
     //on commenting it out and running the SP

    set @counter = @counter + 1
    set @exists = 0
    set @rows = 0

   end
end

return

© Stack Overflow or respective owner

Related posts about sql

Related posts about stored-procedures