OldValue を CDATA にラップするにはどうすればよいですか?
SELECT
1 AS Tag,
0 AS Parent,
(
SELECT PositionDescription AS 'data()'
FROM dbo.Project where ID = 32
FOR XML PATH('')
) AS 'PositionDescription!1!OldValue!CDATA'
FOR XML EXPLICIT, TYPE
OldValue を CDATA にラップするにはどうすればよいですか?
SELECT
1 AS Tag,
0 AS Parent,
(
SELECT PositionDescription AS 'data()'
FROM dbo.Project where ID = 32
FOR XML PATH('')
) AS 'PositionDescription!1!OldValue!CDATA'
FOR XML EXPLICIT, TYPE
TYPE キーワードを削除するだけです。サブクエリで XML ではなく生の文字列を使用する
SELECT
1 AS Tag,
0 AS Parent,
(
SELECT PositionDescription
FROM dbo.Project where ID = 32
) AS [PositionDescription!1!OldValue!CDATA]
FOR XML EXPLICIT
サンプルと出力
create table Project (PositionDescription varchar(100), id int)
insert project select 'abc<test>', 32
---
<PositionDescription>
<OldValue><![CDATA[abc<test>]]></OldValue>
</PositionDescription>