The semantic meaning is different. The first example creates an integer column with a sequential value.
The second example, using identity() , creates an identifier column. This means that subsequent inserts will increase.
For example, run this code:
select 'a' as x, identity(int, 1, 1) as id into
As for processing, they should be essentially the same in your case, since firstname needs to be sorted. If the rows were wider, I would not be surprised if the row_number() version left another in performance. With row_number() only one column is sorted and then mapped back to the original data. With identity() you need to sort the entire row. This performance difference is just a predicted assumption.
source share