Link to home
Start Free TrialLog in
Avatar of nick210577
nick210577

asked on

What's wrong with the following statement. It keeps returning Null?

I've never used an SQL if statement before.  @DaysUsed does in certain circumstances  = Null but I need it to be zero for later calculations.  @DaysUsed is a int.  I don't understand why if the statement is true it doesn't set the variable to 0?
If @DaysUsed = NULL 
 
Begin
Select @DaysUsed = 0
End
 
Select @DaysUsed

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or
 
Select @DaysUsed = ISNULL(@DaysUsed , 0 )
Avatar of nick210577
nick210577

ASKER

Thanks.... IS not =     How annoying... thanks