Best way to export/import MS Sql 2008 Geography data

我与影子孤独终老i 提交于 2019-12-12 09:37:51

问题


(ANSWER) How to export some Geography data from a Microsoft Sql Server 2008.

You'll need to use the command line argument BCP to dump the data in it's original (native) format to a binary file. Then on the other server you can bulk insert this binary data back into a table of the same strucutre.

here's some code.

Export

Command Line: bcp "geodata.dbo.GeographyData" out "C:\GeoData.bin" -T -n -S <servername>

Notes

  • This uses a Trusted connection
  • use the bcp /? for more help for your export options if u need to be hardcore.

Importing the data

T-SQL: bulk insert GeographyData from 'C:\GeoData.bin' with (dataFileType='Native')

I learnt all this through the Spatial guru Isaac Kunen and with the help of Kent Tegels, in this discussion thread here.

The reason for the BCP method is highlighted by Isaac in this quote:

Its worth pointing out that WKB is a lossy format, in that it does not store the SRID. So if you extract and insert the WKB, you'll have to carry the SRID yourself. Our internal binary format does store the SRID, so a BCP like this should be less hassle.

HTH.

EDIT: Replaced entire post question as a community wiki .. this this Post being an answer.


回答1:


I originally removed the question in the opening post, to replace it with the answer (at the end of '08) ... and make it a wiki.

So yeah .. the OP is the answer :P




回答2:


bulk insert error!!! Msg 6522, Level 16, State 1, Line 1 A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry":



来源:https://stackoverflow.com/questions/282604/best-way-to-export-import-ms-sql-2008-geography-data

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