FOR XML AUTO 返回结果: <Categories CategoryID="1" Picture="dbobject/Categories[@CategoryID=''''1'''']/@Picture"/> 使用ELEMENTS方式, 查询语句: SELECT CategoryID, Picture FROM Categories WHERE CategoryID = 1 FOR XML AUTO,ELEMENTS 返回结果: <Categories> <CategoryID>1</CategoryID> <Picture>dbobject/Categories[@CategoryID=''''1'''']/@Picture</Picture> </Categories>
二.使用RAW模式 使用RAW模式不能使用ELEMENTS选项。 1.简单查询 查询语句: SELECT CategoryID, CategoryName AS Nanme FROM Categories WHERE CategoryID < 3 ORDER BY CategoryID DESC FOR XML RAW 返回结果: <row CategoryID="2" Nanme="Condiments"/> <row CategoryID="1" Nanme="Beverages& 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> |