NULL value in the calculations

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 942
DECLARE @Var INT 
select @Var+getdate()+702.67 as t

/* OUTPUT
t
NULL
*/
GO
--By assinging deafult value while declaration itself
DECLARE @Var INT = 0
select @Var+getdate()+702.67 as t
GO
/*
t
2016-08-12 03:48:53.713
*/
--By using ISNULL/ COALESCE function
DECLARE @Var INT
select ISNULL(@Var, 0)+getdate()+702.67 as t
/*
t
2016-08-12 03:48:53.747
*/

Comments or Responses

Login to post response