Is it a good idea to use CTE over Cursor?
In a Table Variable I created a RowId column and in a WHILE loop I used SELECT to get rows by RowID and then performed UPDATE.
Someone recommended to use a CTE as it is more flexible to use. You don't have to use RowId and SELECT instead it just works like Cursor.
The CTE code used is as below:
;With CTE (num) As ( select unqnum from t1 ) update T2 set T2.sales = T2.sales + 1 from CTE inner join T2 on CTE.num = T2.unqnum
I want to know whether CTE is good if you want to perform UPDATE row-by-row on over 2000 rows.