Difference among these Three
1. select count(*),count(1),columnname(*) from table in sql server.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Apr 2, 2014, 7:25 AM
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.
Munesh SharmaPosted Apr 2, 2014, 7:17 AM
You go on this link
And another difference is that count(1) it is faster.