SQL Server 2008 saves geography point as hex

荒凉一梦 提交于 2021-02-10 05:12:01

问题


I've recorded my track to a text file and now I'd like to insert it into SQL Server 2008 R2 database's table as a Point type.

I read my text file using OpenRowSet and insert each line into temporary table. Then I parse every row and insert right values to real table. Each row in file looks like:

$GPRMC,101142.415,A,6210.1547,N,02929.2220,E,3.9,231.8,150310,,,A*62

I'm parsing latitude and longitude with such a code:

INSERT INTO Track(Point)
SELECT
geography::Point(
SUBSTRING(entry,21,2)+'.'+SUBSTRING(entry,23,2)+
SUBSTRING(entry,26,CHARINDEX(',',entry,26)-26),
SUBSTRING(entry,33,3)+'.'+SUBSTRING(entry,36,2)+
SUBSTRING(entry,39,CHARINDEX(',',entry,39)-39)
,4326)
FROM #MYTEMP

After that when I'm looking into real table (named Track) I see something like that:

Point
0xE6100000010CE200FA7DFF0C4F40B43C0FEECE4A3D40

Those points are placed in the right positions on map (using Spatial results tab in SQL Management Studio) but is there any possibility to see them as normal geographical values in a database?


回答1:


Call .STAsText() / .ToString() / .AsTextZM() on the value to see it in human readable form.




回答2:


I came here to say what Martin Smith said. However, it's your lucky day. Today is "teach a (wo)man to fish day". Take a look at the geography methods available. Also note in the "See also" section that there are yet more available.



来源:https://stackoverflow.com/questions/10470756/sql-server-2008-saves-geography-point-as-hex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!