SQL Express connection issues
Once in while I run into problems connecting to a local SQL express instance. This time I was installing an application that needed an SQL express instance to handle its data. While installing this application it kept having problems connecting to the local SQL instance. A test as pointed out on the applications website stated to run sqlcmd -S
HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi
shing a connection to the server. When connecting to SQL Server 2005, this failu
re 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.
The obvious solution is to enable client and server protocols in SQL Server Configuration Manager.
But after that sqlcmd still couldnt connect to the local SQL instance.
The solution to this problem is changing port number in the TCP/IP protocol (the error states a named pipe issue)
Check for the portnumber SQL express uses in the SQL Server configuration manager;
In the left pane, SQL Server Network Configuration -> Protocols for SQL Express, in the right pane open the TCP/IP properties,
click the IP Addresses Tab and look at the bottom for TCP Dynamic Ports (Default is 1433).
Then in the leftpane under SQL Native Client Configuration, open Client Protocols and open the TCP/IP Properties, in the first row tou see the default port.
In my case this port was different then 1433 (a random 1510 in my case), and when changing this port to 1433 sqlcmd worked and this application installed succesfully.








