2008-09-22 31 views
4

我可以通过sqlcmd从DOS命令窗口连接到我的SQL Server数据库,但不能从Cygwin窗口连接到我的SQL Server数据库。从DOS:从cygwin窗口连接到SQL Server超时,从DOS提示符工作

F:\Cygnus>sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS 

测试

(受影响1行)

F:\Cygnus> 

=================== =================================

cygwin的版本:

$ sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS 

HResult 0x35, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [53]. Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.. Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

回答

8

反斜杠是由Cygwin的bash shell中食用。尝试加倍它:

sqlcmd -Q "select 'a test'" -S .\\SQLEXPRESS 
+0

咄。那就是......已经远离* nix太久了。谢谢! – DCookie 2008-09-24 00:00:04

0

您可能必须允许这种远程连接,并提供完整的服务器名称即SERVER \ SQLEXPRESS

0

您也可以通过查询/指令DB和接收在外壳的输出,如果你使用“-Q”开关:

sqlcmd -Q "select * from nice.dbo.TableName ac ORDER BY 1 DESC" -S server_name\\db_name