Pages

Saturday, January 31, 2009

Count No Of Records in a Table

What is the fastest way to check whether Table has any records or not???

Most of the people use count(*) or count(1) or TOP keywords to answer the above question. But you know what if you use above methods, it will take long time if the table has millions of records.

Instead what you can do is, use the below query to see get the answer.

SELECT rows FROM sysindexes WHERE id = OBJECT_ID('EMP') AND indid < 2

No comments: