views:

2105

answers:

2

(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.

A: 

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":

dude -> we're using GEOGRAPHIES ... not geometries. make sure you've got your data type, right.
Pure.Krome
A: 

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

Pure.Krome