SQLCMD 返回命名管道错误

Chr*_*low 1 sql-server sqlcmd

我正在尝试使用 sqlcmd 从命令行运行来自 SQL Server Express 的任何命令。这是一个例子。

sqlcmd -U myname-P mypwd -S mysys/SQLEXPRESS -d MASTER -Q "Select count(*) from sys.databases"
Run Code Online (Sandbox Code Playgroud)

我不断收到以下错误。它似乎试图使用命名管道进行连接,但我已将 SQL Express 配置为使用 TCP。如何让 SQLCMD 不使用命名管道?

Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Named Pipes Provider: 
    Could not open a connection to SQL Server [67]. .
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 11 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..
Run Code Online (Sandbox Code Playgroud)

Aar*_*and 6

服务器名称和实例名称应该用反斜杠分隔,而不是正斜杠。尝试:

sqlcmd -U myname -P mypwd -S mysys\SQLEXPRESS -d master -Q "Select count(*) from sys.databases"
Run Code Online (Sandbox Code Playgroud)