Need a cursor to update a value from another stored procure and updates only selected values
I have the following:
DECLARE upd_cursor CURSOR FOR
SELECT * FROM Terr
WHERE Text = "RightT" ;
OPEN upd_cursor;
-- Perform the first fetch.
FETCH NEXT FROM upd_cursor;
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
exec usp_Gent @valback OUTPUT;
update Terr
set Text = @valback
FETCH NEXT FROM upd_cursor;
END
CLOSE upd_cursor;
DEALLOCATE upd_cursor;
GO
In my case, it updates all of the field in the table. What am I doing wrong
If you really wanted to do a row by row update you could use
CURRENT OFsyntax. This would be the case if your call to the stored procedure returned different results on each.e.g.