Reputation: 210
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 ORM to communicate to the database in order to save it.
Upvotes: 2
Views: 184
Reputation: 12401
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
Upvotes: 2