Scenario : You have a table that has a lot of rows and you want to know the total number of rows.
Solution 1 : The classic solution is SELECT COUNT(*) FROM TableName but this can take a while.
Solution 2 : The faster way to get the record count would be one of the choises below :
- SELECT SUM(1) FROM TableName
- SELECT COUNT(1) FROM TableName
- SELECT ROWS FROM SYSINDEXES WHERE OBJECT_NAME(ID) = 'TableName' and indid<2
- EXEC SP_SPACEUSED 'TableName'
- DBCC CHECKTABLE(''TableName)
Lucian Leonte
MCT, MCITP, MCTS
Powered by CodeReview – Let's make it Better!