Whether you should or should not expect a result from an empty table depends
not on any property of the aggregate, but rather on your query and what's
being grouped. Take the following, for example:
----
create table #x(id int, id2 int)
--Produces an empty set because there are no groups of id2 on which to
aggregate
select avg(id), id2
from #x
group by id2
--Produces a NULL because you're treating the table as a single group
select avg(id)
from #x
----
Your user-defined aggregates will perform the same way. IsNullIfEmpty is
essentially a performance hint. It tells the optimizer that if a particular
group is empty -- that is, Accumulate has not been called -- that there is
no need to call Terminate for the group. The optimizer can simply set the
output to NULL instead.
--
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Leila" <Leilas@hotpop.com> wrote in message
news:uUcvCt5LGHA.3064@TK2MSFTNGP10.phx.gbl...
|