Reputation: 93
Is there a better way to do this or is this code ok?
DECLARE @Test DECIMAL(18,2) = NULL
, @Test1 DECIMAL(18,2) = '5'
SELECT ISNULL(@Test,(ISNULL(@Test1,'0')))
Thanks, EB
Upvotes: 1
Views: 35
Reputation: 175606
There is no need for nesting ISNULL
. You could use COALESCE
:
Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL
DECLARE @Test DECIMAL(18,2) = NULL , @Test1 DECIMAL(18,2) = 5;
SELECT COALESCE(@Test, @Test1, 0);
Upvotes: 5