Delete in cursors - TSQL Tutorial

In this page you can learn how to delete rows from table and views using delete operation in cursors.


Delete in cursors example:

USE model;
GO
DECLARE MyCursor CURSOR FOR
   SELECT *
   FROM dbo.students
   WHERE first_name = 'David' AND last_name = 'BROWN' AND id = 6 ;
OPEN MyCursor;
FETCH FROM MyCursor;
DELETE FROM dbo.students WHERE CURRENT OF MyCursor;
CLOSE MyCursor;
DEALLOCATE MyCursor;
GO