开发者

How do I save xml exactly as is to a xml database field?

At the moment, if I save <element></element> to a SQL Server 2008 database in a field of type xml, it converts it to <element/>.

How can I preserve the xml empty text as is when saving?

In case this is a gotcha, I am utilising Linq to Sql as my 开发者_StackOverflow社区ORM to communicate to the database in order to save it.


What you're asking for is not possible.

SQL Server stores data in xml columns as a binary representation, so any extraneous formatting is discarded, as you found out.

To preserve the formatting, you would have to store the content in a text field of type varchar(MAX) or nvarchar(MAX). Hopefully you don't have to run XML-based queries on the data.

http://msdn.microsoft.com/en-us/library/ms189887.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜