【问题标题】:SQL Geography string parsingSQL 地理字符串解析
【发布时间】:2010-11-19 21:03:18
【问题描述】:

为什么会这样

select geography::STGeomFromText('POINT(-77.010996 38.890358)',4326)

但这不是

declare @Latitude decimal(9,6) = 38.890358  
declare @Longitude decimal(9,6) = -77.010996

select geography::STGeomFromText('''POINT(' + 
cast(@Longitude as nvarchar(15)) + ' ' + 
cast(@Latitude as nvarchar(15)) +')''',4326)

我错过了什么,它们似乎实际上是同一件事。

【问题讨论】:

    标签: sql-server tsql geospatial geography


    【解决方案1】:

    去掉开头和结尾的多余引号

    declare @Latitude decimal(9,6) = 38.890358  
    declare @Longitude decimal(9,6) = -77.010996
    
    select geography::STGeomFromText('POINT(' + 
    cast(@Longitude as nvarchar(15)) + ' ' + 
    cast(@Latitude as nvarchar(15)) +')',4326)
    

    【讨论】:

    • 哇,我觉得自己像个傻瓜。只是那些大脑放屁的时刻之一,谢谢。
    猜你喜欢
    • 2021-03-02
    • 2010-10-13
    • 1970-01-01
    • 2021-02-18
    • 2013-05-18
    • 1970-01-01
    • 2014-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多