每当我将一个字符串解析为SQL XML数据类型时,我注意到当混合使用空格和XML回车符时,回车符会消失。如果它们没有混合使用,则一切正常。有人知道这是为什么吗?
请参见下面的SQL示例代码。
请参见下面的SQL示例代码。
DECLARE @var XML
PRINT 'This is a statement with two XML carriage-return characters'
SET @var = CONVERT (XML,'<root>Dear Sir,

I am passing CR</root>',1)
SELECT @var
PRINT 'output is identical to a statement with two whitespace carriage-return characters'
SET @var = CONVERT (XML,'<root>Dear Sir,
I am passing CR</root>',1)
SELECT @var
PRINT 'Why does this statement only display one space? There is an XML carriage-return AND a whitespace carriage-return character.'
--Make sure there is no space after 
 after you've copied and pasted the code
SET @var = CONVERT (XML,'<root>Dear Sir,
I am passing CR</root>',1)
SELECT @var