This question already has an answer here:

I'm testing this command to migrate GeoJSON data to MSSQL table:

ogr2ogr -f MSSQLSpatial "MSSQL:server=.\SQLEXPRESS;database=geodb;trusted_connection=yes" test.json -nln test

It works beautifully, but if json data contains other characters then ASCII I get garbage in MSSQL table for that field:

enter image description here

Json file is UTF-8 encoded without BOM header.

I tried appending -lco ENCODING=UTF-8 parameter to ogr2ogr command, but that didn't help.

So I wonder if anyone knows how to set sqlserver and ogr2ogr to communicate Unicode?

marked as duplicate by Andre Silva, whyzar, LaughU, BERA, Jochen Schwarze Jan 18 at 19:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I would make a test by converting first into GML and then to MSSQL. If needed, check the charset parameter of the GML file and perhaps run the file through iconv. Not for a final solution but it may give more information about what is going on. – user30184 Jun 2 '14 at 21:30
  • It's just the same. Both GeoJSON and now converted GML, render fine in UTF-8 text editor, but not in database table. – zetah Jun 2 '14 at 22:17
  • I do not believe that -lco ENCODING=UTF-8 has any effect because the driver does not seem to have such layer creation option gdal.org/drv_mssqlspatial.html. This issue may deal with support.microsoft.com/kb/239530 and trac.osgeo.org/gdal/ticket/5239. – user30184 Jun 3 '14 at 4:51
  • So this task is impossible currently. Thanks for the information. – zetah Jun 3 '14 at 23:20
  • 1
    Well, open ticket you linked and this question show that there is no way to import Unicode with org2org to mssqlserver. UTF-8 data is passed to mssqlserver, but it doesn't recognize it as such because the column type is set to varchar instead nvarchar. If column is set to nvarchar, mssqlserver would apparently import UTF-8 data and convert it on the fly to it's Unicode encoding variant - UTF-16LE. – zetah Jun 4 '14 at 4:38

Browse other questions tagged or ask your own question.