Count(*)

  • Hi everybody,

    I got a problem with the count(*) function.

    When I do :

    Select count(*) from EmptyTable1 it return me 0

    Of course there is no record in the table

    BUT! when I do

    select count(*) from EmptyTable1

    inner join EmptyTable2 on 1=1

    It does not return me 0 even if the two tables are empty, it returns me nothing, an empty recordset. Not even a Null value.

    Is there a way in SQL to correct that?

    Thank you,

    DaSaint

  • Sorry,

    The problem is the GROUP BY clause like this :

    select count(*) from EmptyTable1

    group by AnyTableOneField

    it returns me nothing but an empty recordset.

    Is there a way to correct this in SQL

    Thanks again,

    DaSaint

  • Check @@RowCount and return a zero if its zero.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply