![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
select CONVERT(VARBINARY(max), c1, 1) from kmtest; |
#2
| |||
| |||
|
|
Hi, I inserted data with whitespace in XML column and the space is stored as entitized string "& # x 2 0 ;". MSSQL seems to entitize some characters during serialization. Some characters are &, <, >, white-space, TAB, linefeed, carriage return, and surrogate pairs and so on. I found the document which says that if we want to avoid entitization, we can use the explicit CONVERT option 1 when casting from xml to a string or binary type. select CONVERT(VARBINARY(max), c1, 1) from kmtest; (there is one space in front of the xml document) insert into kmtest values(convert(xml,' <a><b></b></a>',0)); <== strip whitespace insert into kmtest values(convert(xml,' <a><b></b></a>',1)); <== preserve whitespace select CONVERT(VARBINARY(max), c1) from kmtest; ----------------------------------------------------------------------------- 0xFFFE3C0061003E003C0062002F003E003C002F0061003E00 0xFFFE260023007800320030003B003C0061003E003C006200 2F003E003C002F0061003E00 select CONVERT(VARBINARY(max), c1, 1) from kmtest; ----------------------------------------------------------------------------- 0xFFFE3C0061003E003C0062002F003E003C002F0061003E00 0xFFFE20003C0061003E003C0062002F003E003C002F006100 3E00 Is there any other way to avoild entitized string? I think it may cause some performance problem when we need to convert whole XML document into string or binary data types... I think XQuery method query() can be used to retrieve the data, but I would like to select the whole document incuding elements... Thank you, KM |
![]() |
| Thread Tools | |
| Display Modes | |
| |