Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SET @ASACCRUED = @ASACCRUED+@MMINTR


if @ASACCRUED is null

What I have tried:

Checked my codes to see if there is something like that
Posted
Updated 14-Feb-17 19:00pm

use IsNull[^] to replace the null value with a specified value
SQL
SET @ASACCRUED = isnull( @ASACCRUED,0)+@MMINTR
 
Share this answer
 
check this out: ISNULL (Transact-SQL)[^]
 
Share this answer
 
--Assume if @MMINTR = 1
--if @ASACCRUED is null
DECLARE @ASACCRUED INT = 1,
@MMINTR INT = NULL

SET @ASACCRUED = IIF( @ASACCRUED IS NULL, 0 , IIF( @MMINTR IS NULL, 0 , @ASACCRUED + @MMINTR ) )
SELECT @ASACCRUED
 
Share this answer
 
v2
Comments
CHill60 22-Mar-17 10:12am    
IIF is non-standard SQL that only appears in SQL Server up to 2008 and then again from 2012. It's only included for Access compatibility and is actually translated to a CASE statement anyway. It only works with SQL Server and is not portable to other platforms.
But even CASE is a bit of a long-winded way of approaching this problem. ISNULL is the most efficient, COALESCE would be the next best

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900