使用SQL生成KML文件时出错

时间:2016-08-09 20:48:36

标签: sql xml kml google-earth

我想用sql生成kml文件来定位google earth中的一些点。我有这段代码:

with xmlnamespaces(default 'http://www.opengis.net/kml/2.2')
select(
    select PERIODO_ALTA as name,
           1 as visibility,(
        select(
            select PAGO_ANT_60DF as name,
                mir_mdf_troba as description,
                MIR_COORD_X_LON+','+MIR_COORD_Y_LAT+',0' as 'Point/coordinates'
            )for xml path('Placemark'), type           
        )from CB_IC_FIJA_AN_CONSOLIDADO_RECIBOS_3X
        WHERE DEPARTAMENTO ='LA LIBERTAD'
        AND MIR_COORD_Y_LAT IS NOT NULL AND MIR_COORD_Y_LAT<>'0'
    for xml path('Folder'), type
)for xml path('Document'), root('kml');

并收到此错误消息: Msg 116,Level 16,State 1,Line 9 当未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式。

1 个答案:

答案 0 :(得分:0)

解决了,谢谢!

with xmlnamespaces(default 'http://www.opengis.net/kml/2.2')
select (
       select Distrito+MDF_TROBA_NOMBRE as name,
              'MIR' as description,
              (
                select 0 as extrude,
                       'relativeToGround' as altitudeMode,
                       '-76.90695,-11.99474 -76.90292,-11.99533 -76.90086,-12.01296 
                       -76.90343,-12.01388 -76.90627,-12.01019 -76.90695,-11.99474' 
                       as 'outerBoundaryIs/LinearRing/coordinates'
                for xml path('Polygon'), type
              )
       from MIR_FIJA_MAESTRA_CAB
       for xml path('Placemark'), type
       )
for xml path('Document'), root('kml');