我正在尝试从包含Geography类型的表中返回XML SQL查询:
SELECT *
From Events
ORDER BY HydrantId ASC
FOR XML RAW ('Event'), ROOT ('Events'), ELEMENTS XSINIL;
我收到以下错误:
FOR XML does not support CLR types -
cast CLR types explicitly into one of the supported types in FOR XML queries.
如何将此地理位置列转换为可读的内容? 感谢。
答案 0 :(得分:3)
SELECT Column1, Column2, Column3, cast(GeographyColumn as varchar(max))
From Events
ORDER BY HydrantId ASC
FOR XML RAW ('Event'), ROOT ('Events'), ELEMENTS XSINIL;
GeographyColumn
中的值将采用POINT (-77.010996 38.890358)
格式。