34
votes

I just installed SQL Server Express 2008 R2 and I have a problem connecting to it using the SQL Server Management Studio (locally).

All SQL Server services are started (SQL Server (SQLEXPRESS), SQL Server browser, also the DTC service)

When I try to connect I get the following message:

TITLE: Connect to Server

Cannot connect to (local).

ADDITIONAL INFORMATION:

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) (Microsoft SQL Server, Error: 2)

4
Try connecting to whatever your machine name is instead of local... it seems to be a bit flakey sometimesforsvarir
Answer: In the server name field I chnged from '(local)' to '[Comp-Name]\SQLEXPRESS'Alon Ashkenazi

4 Answers

82
votes

Are you connecting to the local express instance? Try this as your server: .\SQLEXPRESS

16
votes

The same error can happen if your SQLEXPRESS instance is not started. To verify the service is started: - run services.msc - Look for the "SQL Server (SQLEXPRESS)" service, status should be "Started", if it is not, try to start it manually.

12
votes

I had the same error and I had to enable TCP/IP protocol and set IPALL TCP Port to 1433 to resolve the issue:

SQL Server Configuration Manager settings

0
votes

hope it will help you

 server name try this: (local)\SQLEXPRESS or localhost\SQLEXPRESS.

it is working.....