Home Forums SQL Server 2005 T-SQL (SS2K5) Replacing NULL with 0 when using the Pivot operator RE: Replacing NULL with 0 when using the Pivot operator

  • Matt Miller (6/18/2008)


    I usually end up handling that in the outer select. Meaning - once the PIVOT has been done.

    Something like:

    select locationname,

    isnull([2008-03],0) as [2008-03,

    etc...

    You certainly could do it with some kind of a UNION ALL, assuming the extra rows don't somehow mess up the aggregation.

    I also handle this in the outer query. You can use isnull or coalesce to substitute a 0 for null values.