Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to SQL Server from cygwin window times out, from DOS prompt works

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.

like image 935
DCookie Avatar asked Mar 02 '23 07:03

DCookie


1 Answers

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

sqlcmd -Q "select 'a test'" -S .\\SQLEXPRESS
like image 118
Adam Mitz Avatar answered Mar 03 '23 22:03

Adam Mitz