I can't connect to ms sql instance - internal

I got the same error. It was because I used -H mssqlserver instead of -S mysqlserver

This worked for me

sqlcmd -U sa -S mssqlserver -P secret

In the question the -P option is used for port and password, but it is only supported for the password.

If e port different from 1433 should be used, then pass it with the host name

sqlcmd -U sa -S mssqlserver,1444 -P secret

sqlcmd Install instructions can be found in https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15

In case anybody cares about Emacs Org-babel

#+HEADER: :results table :engine mssql :dbhost mssqlserver :database master :dbuser sa :dbpassword secret
#+begin_src sql
SELECT name, database_id, create_date
FROM sys.databases;
#+end_src

Found in

  • https://www.reddit.com/r/emacs/comments/e9lrcp/how_to_use_sqlmode_or_org_babel_to_execute_mssql/fakr7nw?utm_source=share&utm_medium=web2x
  • https://emacs.stackexchange.com/questions/39112/org-babel-using-properties-as-code-block-header-arguments-how-to-make-it-work