In the test below, I found that NULL bit faster.
SET STATISTICS TIME ON; DECLARE @i int = null; WITH E1(N) AS ( SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 )
At an average of 608 ms to summarize 100,000,000 values. (i.e. 6 nanoseconds per aggregation).
NULL people spend more time on
sqllang.dll!CESRunTimeErrorSink::SetAggFnSkippedNull
Presumably set a flag that will result in a message
Warning: Null is excluded by an aggregate or other SET operation.
But overall it seemed faster (elapsed time in ms lower).
+---------+--------+------++-------+ | | NULL | 0 || Diff | +---------+--------+------++-------+ | Trial 1 | 7027 | 7592 || 565 | | Trial 2 | 6981 | 7743 || 762 | | Trial 3 | 7451 | 8015 || 564 | | Trial 4 | 6997 | 7591 || 594 | | Trial 5 | 7018 | 7574 || 556 | +---------+--------+------++-------+ | Avg | 7094.8 | 7703 || 608.2 | +---------+--------+------++-------+
Of course, in this case (where all the input is NULL ) they return different results, and you need ISNULL(SUM(@i),0) if you want to consider these two interchangeably.
source share