I read in .NET that using case 2 is faster than case 1 to check for rows in a table. so I did a performance test like count (1) vs rowcnt from sys.sysindexes, which I found The second option is much better.
My question is, is it good to use CASE 2 in production code when I need to count the number of rows in a table in stored procedures or special queries, is there any chance this case 2 could fail?
Edited: The number of rows in the table is about 20,000 in this case
DBCC FREEPROCCACHE DBCC DROPCLEANBUFFERS --CASE 1 SELECT count(1) from Sales.Customer c -- 95% --CASE 2 SELECT rowcnt from sys.sysindexes s WHERE id=object_id('Sales.Customer') AND s.indid < 2 -- 5%

source share