While establishing connection to sql sserver the following error may occur
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.
The reason for this error is that in the sql server the remote connection is turned off. In this article i am explains how to turn on remote connection on sql server 2005. To turn remote connection on in sql server follow the below steps
1. Start -> Programs -> Microsoft Sql Server -> Configuration tools -> Sql Server Surface Area connection
2.In the Sql Server Surface Area connection click on Surface Area Configuration for Services and Connections
3. Expand the Database Engine click on remote connections and click on Local and remote connections. click the appropriate protocol to enable for your environment, and then click Apply.
Note Click OK when you receive the following message:
Changes to Connection Settings will not take effect until you restart the Database Engine service.
4. On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.
The following video shows how to enable sql server remote connection
If your error is not resolved another reason for this error is your sql server browser server is turned off. To turn on sql server browser service follow the below steps.
1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
3. On the Surface Area Configuration for Services and Connections page, click SQL Server Browser, click Automatic for Startup type, and then click Apply.
Note When you click the Automatic option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows.