“A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)”. I didn’t get why this happened because previously it worked perfectly. To solve this problem I did some research and found solution at that time I decided to write post to help someone who is in need with this problem. Check below methods to solve this problem.
Now restart your SQL Server Management Studio and check it I hope it will work for you.
First Method
Open SQL Server Management Studio now Connect window will open check whether you given proper Server Type and Server Name or not because if we give incorrect details then we have a chance to get this issue.
Second Method
1. Go to Start >> Select All Programs >> Microsoft SQL Server 2008 R2 >> Configuration Tools >> SQL Server Configuration Manager
(Note: I installed SQL Server is 2008 R2 version in my laptop that’s why I selected Configuration Tools from Microsoft SQL Server 2008 R2 in case yours is Microsoft SQL Server 2008 then select Configuration Tools from that SQL Server version)
2. After open SQL Server Configuration Manager >> Select SQL Server Services >> Select SQL Server (MSSQLSERVER) and check the status of SQL Server (MSSQLSERVER) whether is it running or not
3. If SQL Server (MSSQLSERVER) Status is in Running it’s ok otherwise right click on SQL Server (MSSQLSERVER) and click Start
4. Now select SQL Server Network Configuration >> Select Protocols for MSSQLSERVER >> TCP/IP and check status of TCP/IP whether is it enabled or not if that TCP/IP state is in Disabled state right click on it and Enable that one.
Now restart your SQL Server Management Studio and check it I hope it will work for you.