Alex Gordon
Alex Gordon

Reputation: 60871

Could not open a connection to sql server

i am running this in the command line:

sqlcmd -s .\SQLexpress

and the output i get is:

HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2]. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or in stance-specific error has occurred while establishing a connection to SQL Server . Server is not found or not accessible. Check if instance name is correct and i f SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.

when i run this:

c:\Program Files (x86)\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -sSQLEXPRESS

i get: server error 17058 severity 16, state 1, could not open error log file

however this works:

osql -S .\SQLExpress -E

Upvotes: 4

Views: 34968

Answers (2)

bob
bob

Reputation: 39

This works for me.

1)SQLServer Services / SQL Server PropertieS: Logon as built-in account, LocalSystem

2)Check if all protocols for SQLEXPRESS are enabled shared memory, named pipes and TCP/IP

3)SQL Native Client 11.0 Configuration: Client protocols: Shared Memory, TCP/IP and Named Pipes all ENABLED

4)Added System Environment System > Advacned system settigns> Environmnet Settings>New Variable Name: SQLCMDSERVER
Variable value: \SQLEXPRESS

Rob

Upvotes: 1

Andrey
Andrey

Reputation: 60105

Go to Start -> Run, type "C:\Windows\System32\mmc.exe /32 "C:\Windows\system32\SQLServerManager.msc", then go to SQL Native Client Configuration, Client Protocols and check that shared memory, tcp/ip and named pipes are enabled.

Upvotes: 3

Related Questions