Skip to content
Advertisement

Replace Null with ‘-‘ string in Dynamic Pivot query

I have the following code where I’m trying to dynamically Pivot the table.

Everything seems to be working the way I want except I want to replace the null with ‘-‘.

Any ideas?

Advertisement

Answer

You need to put the coalesce into the dynamic column list – something like this:

The isnull(@Columns1… you have will replace null column names with ‘-‘ rather than null column contents.

Advertisement