Select count(*) returns a null value

  • Hi,

    I have a procedure to calculate the number of work days in a period of time (don't count saturdays and sundays).

    In SQL Server 6.5 it worked fine, but now in SQL 2000 it is not working. The problem is that when select count(*) returns a 0 (Zero), the if changes this value to null, and then compare null with > 0. I tried to use SET ANSI_NULLS on and off, but without success. The server was migrated from 6.5, and the compatibility level is set to 6.5.

    What worries me is that this situation could be happening on other procedures. I can easily replace this procedure, but I rather to discover what's happening.

    Any suggestions ?

    set nocount on

    declare @i int

    set @i = 0

    while @i < 10

    begin

    --print @i

    if ( select datepart(weekday,getdate()+@i) where datepart(weekday,getdate()+@i) not in (1,7) ) > 0 -- is not null

    begin

    print 'a'

    end

    else

    begin

    print 'b'

    end

    set @i = @i + 1

    end

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

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