2008-09-22 42 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