Subject says it all. I would like to change the NULLS to blank in my Dynamic Pivot results. Here is a small sample of data from my DistinctPages table:pageno groupid customized----------- ---------- ----------101105 cshaffre x105101 cshaffre x105110 cshaffre x122566 cshaffre x100100 darryl x101100 darryl x103800 darryl x100110 darryl x122201 dbouma x101151 dbouma x107102 dbouma x104102 dbouma x105121 dbouma x
Here is the dynamic code I have:DECLARE @query VARCHAR(4000), @groupids VARCHAR(8000)SELECT @groupids = STUFF(( SELECT DISTINCT '],[' + LTRIM(groupid) FROM DistinctPages ORDER BY '],[' + LTRIM(groupid) FOR XML PATH('') ), 1,2, '') + ']' SET @query ='SELECT * FROM (SELECT pageno, groupid, customized FROM DistinctPages)tPIVOT (MAX(customized) FOR groupidIN ('+@groupids+')) AS CustomizedPagesPerGroups'EXECUTE (@query)
Here is a small sample of my pivot table results:pageno cshaffre darryl dbouma dsanders eliteadm FIRM french Gerry Ilee Irene lgentry matt mduran Mine mpadilla mwilton pmp rlandsin spanish sverne swachman train train01 vicky vlad VTest vvargas ymalluf----------- -------- ------ ------ -------- -------- ---- ------ ----- ---- ----- ------- ---- ------ ---- -------- ------- ---- -------- ------- ------ -------- ----- ------- ----- ---- ----- ------- -------100100 NULL x x x x x x x x NULL x x NULL NULL x x NULL x x x x x x x x x x NULL100101 NULL NULL NULL NULL x x x NULL NULL NULL NULL NULL NULL NULL NULL NULL x x x NULL NULL NULL NULL NULL x NULL NULL NULL100102 NULL NULL x NULL x x x x x NULL x x NULL NULL x NULL NULL x x x x x NULL NULL NULL NULL x NULL100104 NULL NULL NULL NULL NULL NULL x NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL x NULL NULL NULL NULL NULL NULL NULL NULL NULL100110 NULL x x NULL NULL NULL x NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL x NULL NULL NULL NULL NULL NULL NULL x NULL100113 NULL NULL x NULL NULL NULL x NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL x NULL NULL NULL NULL NULL NULL NULL NULL NULL100115 NULL NULL NULL NULL NULL NULL x NULL x NULL NULL NULL NULL NULL NULL NULL NULL NULL x NULL NULL NULL NULL NULL NULL NULL x NULL
I would like to replace the NULLs you see with a blank or some other text that makes it easier to read.I was looking into ISNULL and COALESCE but I have not been able to implement it correctly.Can someone take a look at my code and give me an example of how to do what I need with either ISNULL or COALESCE? Please let me know if you need anything else.