問題描述
如何在 SQL 中對 XML 屬性進(jìn)行排序?
How to sort XML Attributes in SQL?
例如對于這個(gè) XML:
for example for this XML:
<books><book b='' c='' a=''/></books>
我想要:
<books><book a='' b='' c=''/></books>
推薦答案
來自 http://msdn.microsoft.com/en-us/library/ms187107%28v=sql.90%29.aspx:
不保留 XML 屬性的順序.當(dāng)您查詢XML 實(shí)例存儲在 xml 類型列中,屬性在生成的 XML 可能與原始 XML 實(shí)例不同.
The order of the XML attributes is not preserved. When you query the XML instance stored in the xml type column, the order of attributes in the resulting XML may be different from the original XML instance.
因此,即使您能想出一種對屬性進(jìn)行排序的方法,您也不能相信 SQL Server 中的 XML 數(shù)據(jù)類型會保留您想要的順序.
So even if you could figure out a way of sorting the attributes, you can not trust that the XML data type in SQL Server will preserve the order you want.
這篇關(guān)于在 SQL 中對 XML 屬性進(jìn)行排序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!