Difference among these Three
1. select count(*),count(1),columnname(*) from table in sql server.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 2, 2014, 3:17 AM EDT
You go on this link
And another difference is that count(1) it is faster.
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 2, 2014, 3:25 AM EDT
Hi,
There is no difference in output. but as a performance tip all experts are suggest to use count(1) or Count(columnname) instead of Count(*)
I think, for count(1), Internal mechanism of SQL server check whether the row exist or not
for Count(*) it will fetch whole row and returns row count.
it may be execution plan are different.