I have a stored procedure that executes indefinitely. I can't see where I have created an infinite loop or anything. Any suggestions as to why this keeps executing?
ALTER PROCEDURE sp_RemovePaddingPicture_Name
AS
BEGIN
SET NOCOUNT ON;
DECLARE @test nvarchar(50)
DECLARE cur CURSOR FOR
SELECT Picture_Name
FROM PEOPLEGENERAL
OPEN cur
FETCH FROM cur
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE PEOPLEGENERAL
SET PICTURE_NAME = RTRIM(PICTURE_NAME)
WHERE CURRENT of cur
FETCH NEXT FROM cur
END
CLOSE cur
DEALLOCATE cur
END
I created this stored procedure to update a column. It keeps executing.
1条答案
按热度按时间tcomlyy61#
You are not doing anything with the value returned from the cursor for one thing.
That all said you could also just do this with one statement provided the table is not that large that it would cause an issue.
or if there are only a limited number of records that should be touched because the value is the same.