create table #t
(a int
,b nvarchar(20)
)
go
insert into #t values(1,'a&b')
insert into #t values(1,'c<
d')
insert into #t values(2,'wx')
insert into #t values(2,'yz')
go
select a,b,
(select b+N''
from #t
where a=t.a
for xml path('')
) 'WITH xml CHARACTERS'
,replace(
replace(
replace(
replace(
replace(
replace(
replace(
(select b+N''
from #t
where a=t.a
for xml path('')
)
,' ',char(20))
,'&','&')
,'<','<')
,'>','>')
,'
',char(10))
,'
',char(13))
,' ',char(9)) 'With XML Replaced'
from #t t
go
drop table #t
|