Last post Dec 22, 2018 07:35 PM by mgebhard
Dec 22, 2018 05:17 PM|gunderj|LINK
The below example uses FOR XML PATH to flatten a column that includes html tags. Somehow the html tags get converted which causes our razor page Html.Raw helper to include the html tags in its output. Executing the below shows that the FOR XML PATH does
flatten the column ocrrectly, but converts my html tags which are then unusable by Html.Raw.
Here is the sample with the result...
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[test_line_v]'))
DROP VIEW [dbo].test_line_v
create view test_line_v as
select 1 email_id,'<p>This is line one</p>' body
union select 1,'<p>This is line two</p>'
STUFF((SELECT DISTINCT ', ' + body AS [text()]
FROM test_line_v b
WHERE b.email_id = a.email_id
FOR XML PATH('')), 1, 2, '')
from st_notification_email a join test_line_v b
on (a.email_id = b.email_id)
result: <p>This is line one</p>, <p>This is line two</p>
Thanks for any help.
Dec 22, 2018 07:35 PM|mgebhard|LINK
This question has been answered in your
previous thread. HtmlDecode the string!