microsoft / go-sqlcmd

The new sqlcmd, CLI for SQL Server and Azure SQL (winget install sqlcmd / sqlcmd create mssql / sqlcmd open ads)

Home Page:https://learn.microsoft.com/sql/tools/sqlcmd/go-sqlcmd-utility

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sqlcmd.exe not run under Windows 10

virtualdreams opened this issue · comments

I downloaded and unzipped the version "sqlcmd-v1.3.0-windows-x64.zip". But the binary sqlcmd.exe brings the following error under cmd or powershell.

C:\Tools\sqlcmd-v1.3.0-windows-x64>sqlcmd
The system cannot find the specified file.
The system cannot find the specified file.

C:\Tools\sqlcmd-v1.3.0-windows-x64>

Tried on Windows 10, Windows 10 TS, Windows Server 2022

do you have a local SQL Server running using Windows authentication?
Does sqlcmd --help print anything?

Do you get the same error if you run .\sqlcmd.exe?

No matter if I type sqmlcmd.exe or .\sqlcmd.exe, the error always comes up. Also with cmd /K sqlcmd.exe or start sqlcmd.exe.

One of the systems is running a SqlServer, the others are only clients.

sqlcmd.exe --help works.

Must say that the SqlServer is running in single user mode, because I need to restore the master db (is only test system).

The following command brings the following error:

C:\Tools\sqlcmd-v1.3.0-windows-x64>sqlcmd.exe -S server\TEST01 -E -d master
no named pipe instance matching 'TEST01' returned from host 'server'.
no named pipe instance matching 'TEST01' returned from host 'server'.

You have to enable the named pipes if I read correctly?

oh we have a fix for the named pipe dependency but haven't pushed a release yet.
The workaround is to use -S tcp:server\instance for now.

I think now I have it. It works so far, only I'm not an administrator on the system and can't connect. But it would probably work otherwise.

I will close the bug, even if the first error message is misleading and makes no sense.

sqlcmd tries to connect using TCP then shared memory then named pipes, so the last error is going to be whatever the operating system returns for the named pipe failure.

I don't know if the error can be improved a whole lot. ODBC isn't giving us anything much better. I guess we could add a similar reminder like "check the firewall and protocol settings on the server"

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..