Which is the better method to add the Row Number?
-
3 мая 2012 г. 3:20
Hi All,
I had a requirement in which I need to have a unique row number to the temp table or table variable. One of the method I got was from here. Other is to have a identity column. Performance wise which one is better? Any Suggestion?
Все ответы
-
3 мая 2012 г. 3:38
Identity column value is increased automatically by the Increment value during each insert operation and it would be always unique. In most cases Identity column would be used as the Primary key as well which would be created as a clustered index. I would go for Identity field rather than increasing the number manually..Murali Krishnan
- Предложено в качестве ответа Naomi NMicrosoft Community Contributor, Moderator 3 мая 2012 г. 3:43
-
3 мая 2012 г. 3:43
If you will use IDENTITY column, the overhead on top of pure inserts is minimal (assuming that IDENTITY column is created with the table).
If you will use UPDATE or ALTER TABLE, it will process whole existing table and it is saved second time to disk.
- Помечено в качестве ответа Rishi Daftary 3 мая 2012 г. 3:48
-
3 мая 2012 г. 3:45
So you mean to say Performance wise Identity Column is better than the other way round...

