如何使用Git Bash通过SQLCMD登录到SQL Server?

如何使用Git Bash通过SQLCMD登录到SQL Server?

问题描述:

在我的命令提示符这似乎可以正常使用:如何使用Git Bash通过SQLCMD登录到SQL Server?

sqlcmd -S .\sqlexpress 

但在我的Git的Bash这似乎并没有工作。这是给:

Named Pipes Provider: Could not open a connection to SQL Server [53]. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : 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.. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.

当我留在我的Git Bash很多,我怎么能登录到我的SQL Server通过Git Bash而不经常移动?

我想我需要winpty制作登录工作:

winpty sqlcmd -S .\\sqlexpress

您需要转义反斜线在GIT bash shell中有一个额外的反斜杠分隔实例名称:

SQLCMD -S .\\sqlexpress 
+0

我的Git的bash现在永远在等待,不会返回任何东西 –

+1

你的意思是连接没有超时?奇怪的是,它适用于我。你可以试试'SQLCMD -S localhost \\ sqlexpress'。 –

+0

嗨丹,我终于搞定了:“winpty sqlcmd -S。\\ sqlexpress”:) –