What is the difference between the following two sql
statements
select count(*) from <tablename>
select count(col_name) from <tablename>

Answer Posted / sql2000

There seem to be a problem with the solutions provided by
the above.

Both the counts should provide the same result which is the
no of rows in the table.
count (*) will result in a bigger table scan than count
(col_name) hence its advisable to use count(1) while
calculating the count for a table.

Correct me if I am wrong...:)

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the data type of time?

522


Explain the phases a transaction has to undergo?

558


why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it? : Sql server administration

560


How do I start and stop sql server?

552


Explain primary key in sql server?

572






Can you explain different types of joins?

549


What will be the maximum number of index per table?

592


What is rank function?

604


What are the properties and different types of sub-queries?

568


What are the different types of replication are there in sql server 2000?

566


What is faster join or union?

603


What is the minimum and maximum number of partitions required for a measure group? : sql server analysis services, ssas

602


Does a full backup include transaction log?

485


How to trouble shoot if unable to connect SQL Server

1482


What is cte (common table expression)?

601