I need to query MS Sql Server (running in Docker, Ubuntu) from org-babel. The file name for temporary files that ob-sql assembles doesn't work -- we get, e.g.,

  c\:/tmp/babel-Pey8i9/sql-in-dhrGdF

which produces the error

  Sqlcmd: Error: Error occurred while opening or operating on file c: (Reason: Access is denied).

while the following string works (use backslashes, add quotes).

  "c:\tmp\babel-Pey8i9\sql-in-yQfz4K"


I'm not sure of the best way to submit this. The following change to ob-sql.el works for me, but maybe it wouldn't in other setups with Sql Server.

   (`mssql (format "sqlcmd %s -s \"\t\" %s -i \"%s\" -o \"%s\""
   (or cmdline "")
   (org-babel-sql-dbstring-mssql
    dbhost dbuser dbpassword database)
   (org-babel-sql-convert-standard-filename
             (replace-regexp-in-string "/" (regexp-quote "\\")
                                       (replace-regexp-in-string "c\\\\" "c"
                               (org-babel-process-file-name in-file))))
   (org-babel-sql-convert-standard-filename
             (replace-regexp-in-string "/" (regexp-quote "\\")
                                       (replace-regexp-in-string "c\\\\" "c"
    (org-babel-process-file-name out-file))))))


Johan