views:

943

answers:

2

The title says it all. I can connect to my SQL Server database via sqlcmd from a DOS command window, but not from a Cygwin window. From DOS:

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


a test

(1 rows affected)

F:\Cygnus>

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

From 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.

A: 

You may have to allow remote connections for this, and give the full server name i.e SERVER\SQLEXPRESS

PostMan
+1  A: 

The backslash is being eaten by cygwin's bash shell. Try doubling it:

sqlcmd -Q "select 'a test'" -S .\\SQLEXPRESS
Adam Mitz
Duh. That was it... been away from *nix too long. Thanks!
DCookie