2

我正在尝试从包含 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.  

如何将此地理专栏转换为可读的内容?
谢谢。

4

1 回答 1

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)格式。

于 2012-03-19T18:39:34.130 回答