In this blog post we are going to fix the error which is related to Named Pipes Provider.
Error:
HResult 0x2, Level16, State 1
Named Pipes Provider: Could not open a connection to SQL Server.
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
Solution/Fix/WorkAround:
By default SQL Server 2005 has TCP/IP connections disabled. To enable TCP/IP support, use the SQL Server Configuration Manager tool, select SQL Server 2005 Network Configuration, select Protocols, double-click on TCP/IP, and turn on Enabled.
AND
By default SQL Server 2005 has Named Pipes connections disabled. To enable Named Pipes support, use the SQL Server Configuration Manager tool, select SQL Server 2005 Network Configuration, select Protocols, double-click on Named Pipes, and turn on Enabled.
In the latest version of the SQL Server, I have not seen happening this error anymore. However, it is still relevant and if you are using SQL Server 2005 or 2008, I am sure you will find this error during installation and with the help of this blog you can fix it.
Reference: Pinal Dave (https://blog.sqlauthority.com)