I'm using QGIS 2.0.1 and am connected to a MS SQL Server spatially enabled database (not ESRI). I am able to connect to the layer and load it into my TOC just fine. I have hidden a number of fields that are not important for visibility sake.
Now I want to export that data to another data type (we'll use shapefile for this example). When I right-click the layer, choose "Save As" and define the output file, I get the following error:
Export to vector file failed. Error: unsupported type for field GlobalID
Note 1: If I check "Skip attribute creation" in the dialog box, the shapefile is created with no errors.
Note 2: ArcGIS does not have this problem, it just converts the GUID field to "TEXT" type.
Looking at the table, one of the fields that I have hidden is a GUID of SQL type <uniqueidentifier>, which is in all likelyhood the culprit. In an attempt to resolve this, I made the field "hidden". I would have assumed that because the field was hidden, QGIS would not try to export this field, but that turned out to not be the case.
Can you define the fields you want to export from QGIS?
Is it possible for QGIS to export just the "Visible" fields? Or is there another alternative way of doing this from QGIS (maybe define the fields via an ogr2ogr query)? This seems like a shortcoming of QGIS if I cannot define which fields to export.
UPDATE: I did a test using a sample shapefile to see if I could limit the output fields. The following ogr2ogr command line worked and eliminated all fields except for "name":
ogr2ogr -f "ESRI Shapefile" test.shp city.shp -sql "select name from city"
but using QGIS and adding:
-sql "select name from city"
to the "layer" section of the "Save As" dialog did not result in a shapefile with just the single field. So I don't really see how I can manipulate the file output to show just a select few fields. Any help is appreciated.
-sql "select <fields> from <table>"
(excluding the GlobalID field from the <fields>) to the "Layer" portion of the "Save As" dialog, but the same error still popped up. Did I misuse this code block, or is this a bug?