In this example, we need to update the sales price of each record.We will pass the increased rate and use a cursor to update each record.there are two records with with Id column value as 1) From the above result it is clear that the example 2’s approach 1 and 2 script will not work in the scenarios where we have duplicates in the looping column.Here only one record of the employee with id =1 is displayed and other record is skipped.
When completed, a transaction must leave all data in a consistent state.To create a gap, delete employee record from the #Employee table with id = 2 by the following script: RESULT: Now let us run the example 1’s approach 1 and 2 script on #Employee table which is having gap in the Id column value (i.e. From the above result it is clear that the example 1’s approach 1 and 2 script will not work in the scenarios where we have gap in the looping tables column values.This problem can solved in multiple ways, below are two such example approaches. Approach 1: Looping through table records where looping column has gaps in the value RESULT: Now let us run the example 2’s approach 1 and 2 script on #Employee table which is having duplicate Id column values (i.e.Let me first address the case where the table does not have a unique key. as an integer, and make it an identifier column by checking the identity box in the table design window.