Hello
SQL Server 2000
I'm confused about the difference of the 3 expressions in my thread title - ie, why there isn't a difference when the following is executed:
--DDL
create table #tmp (b int)
insert into #tmp values (30)
insert into #tmp values (null)
insert into #tmp values (30)
insert into #tmp values (30)
insert into #tmp values (30)
--QUERY
select isnull(sum(b),0) SUM1, sum(isnull(b,0)) SUM2, sum(b) SUM3 from #tmp
--Result set
SUM1 SUM2 SUM3
120.00 120.00 120.00
The result set is the same for all three, whether ANSI_NULLS are set to OFF or ON
I was expecting the result set to look more like
SUM1 SUM2 SUM3
0.00 120.00 NULL
because of the NULL value in the column...?
Is this due to some DB setting other than ANSI_NULLS?
Hope this makes sense
Any pointers would be appreciated
Thanks
LFCfan
SQL Server 2000
I'm confused about the difference of the 3 expressions in my thread title - ie, why there isn't a difference when the following is executed:
--DDL
create table #tmp (b int)
insert into #tmp values (30)
insert into #tmp values (null)
insert into #tmp values (30)
insert into #tmp values (30)
insert into #tmp values (30)
--QUERY
select isnull(sum(b),0) SUM1, sum(isnull(b,0)) SUM2, sum(b) SUM3 from #tmp
--Result set
SUM1 SUM2 SUM3
120.00 120.00 120.00
The result set is the same for all three, whether ANSI_NULLS are set to OFF or ON
I was expecting the result set to look more like
SUM1 SUM2 SUM3
0.00 120.00 NULL
because of the NULL value in the column...?
Is this due to some DB setting other than ANSI_NULLS?
Hope this makes sense
Any pointers would be appreciated
Thanks
LFCfan