SQL Server 2008将地理位置保存为十六进制 [英] SQL Server 2008 saves geography point as hex

查看:87
本文介绍了SQL Server 2008将地理位置保存为十六进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将轨迹记录到一个文本文件中,现在我想将它作为Point类型插入到SQL Server 2008 R2数据库的表中.

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.

我使用OpenRowSet读取我的文本文件,并将每一行插入临时表中.然后,我解析每一行并将正确的值插入到实际表中.文件中的每一行都看起来像:

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

之后,当我查看真实表(名为Track)时,我会看到类似的东西:

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

Point
0xE6100000010CE200FA7DFF0C4F40B43C0FEECE4A3D40

这些点位于地图上的正确位置(使用SQL Management Studio中的空间结果"选项卡),但是是否有可能将它们视为数据库中的正常地理值?

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?

推荐答案

致电 .STAsText() / .ToString() / .AsTextZM() 上的值,以易于阅读的形式查看它.

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

这篇关于SQL Server 2008将地理位置保存为十六进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆