Hello there,
A query operation is performed on SQL Server. If the cursor is on the line, the data in that line is processed.
DML (insert – update – delete) operations to be performed on large tables in databases with intense transaction are very risky.
Therefore, the cursor should be used in DML operations.
Example,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
declare @ID varchar(20) declare cursorSK cursor for SELECT birthdate FROM users where birthdate='2050-01-01 00:00:00.000' OPEN cursorSK FETCH NEXT FROM cursorSK INTO @ID WHILE @@FETCH_STATUS = 0 BEGIN --here we can do the process we want the records returned by the row line query. -- Exp: update users set birthdate=null where birthdate=@ID --we are updating the birthdate variables from the above query result to null. FETCH NEXT FROM cursorSK INTO @ID END CLOSE cursorSK DEALLOCATE cursorSK |