Skip to content

Doc: Add MSSQL Driver examples#14405

Draft
geographika wants to merge 1 commit intoOSGeo:masterfrom
geographika:mssql-examples
Draft

Doc: Add MSSQL Driver examples#14405
geographika wants to merge 1 commit intoOSGeo:masterfrom
geographika:mssql-examples

Conversation

@geographika
Copy link
Copy Markdown
Collaborator

Add some MSSQL driver examples, including PowerShell and new CLI. Tested on Windows and Linux.

One point of confusion was if I specified the --layer in the read step of a pipeline I got errors reporting the schema name:

# ERROR 1: Unable to open secondary datasource geo required by JOIN

Example:

  gdal vector pipeline \
      ! read "$conn" --layer "geo.rivers" \
      ! sql --sql "SELECT oid, geom FROM geo.rivers WHERE hydroarea=10" \
      ! write out.gpkg --overwrite

Removing --layer resolved this, so I added it to the docs.

@rouault
Copy link
Copy Markdown
Member

rouault commented Apr 20, 2026

One point of confusion was if I specified the --layer in the read step of a pipeline I got errors reporting the schema name:

trying a bit the same with a shapefile or postgis source, I actually got crashes... Now fixed by bcac881 . But your issue was a bit different. --layer caused ExecuteSQL() to run with OGRSQL instead f MSSQL. Should be fixed per 59e4e1f

@geographika
Copy link
Copy Markdown
Collaborator Author

Thanks @rouault. I'll convert this PR to a draft, retest, and then remove that line from the example.

I did run into another cryptic error (that seemed intermittent):

ERROR 1: An error occurred while writing a dirty block from DropCache

Any ideas what this could mean (and if it should be documented?)

The issue was the account used in $conn2 didn't have trusted access, and I did also get ERROR 1: Unable to initialize connection to the server for ....

gdal vector pipeline \
  ! read $conn1--layer "input.test" \
  ! select --fields "Geom" --output-layer "lyr" \
  ! limit --limit 100 \
  ! sql --sql "SELECT 1 Id, Geom FROM lyr" \
  ! write $conn2 --append --output-layer "output.test"

I also have a note that I got this message when I had the wrong name for a filter step, but I couldn't recreate this.

@geographika geographika marked this pull request as draft April 20, 2026 14:49
@rouault
Copy link
Copy Markdown
Member

rouault commented Apr 20, 2026

Any ideas what this could mean (and if it should be documented?)

this is likely a bug. This is related to the FlushCache() raster logic... Definitely not something to document, but to fix. Any way to reproduce with other datasources than MSSQL... ?

@geographika
Copy link
Copy Markdown
Collaborator Author

Any ideas what this could mean (and if it should be documented?)

this is likely a bug. This is related to the FlushCache() raster logic... Definitely not something to document, but to fix. Any way to reproduce with other datasources than MSSQL... ?

I'll try and recreate with file datasets (it will be at the end of the month). There was definitely no raster data involved though.

@dbaston dbaston added documentation Issues and contributions to the documentation content funded through GSP Work funded through the GDAL Sponsorship Program labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Issues and contributions to the documentation content funded through GSP Work funded through the GDAL Sponsorship Program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants