There can be a situation where you have to use a cursor, even though the experts say not to use cursors or to avoid them as much as possible. But if you look closely, most of the time we use cursors to iterate through a row collection and update the same table.
In these type of situations it is ideal to use a Update Cursor, than using the default read only one.
Consider the following table :
Insert few records to the above table using the following script :
Next we will add a Primary Key using the below script (Or you can use the table designer) :
** Please note: A primary key should be there if we are to use an update cursor. Otherwise the cursor will be read only.
Here is how you use the Update Cursor. I have highlighted the areas which is differ from compared with a normal cursor. You have to mention which column you are going to update (or all columns in your selection will be updatable) and you have to use ‘where current of <cursor>’ in your update statement.