Pages

Monday, July 30, 2012

SQL Express Edition Backup by SQLCMD fails with error ‘Named Pipes Provider: Could not open’

Issue

Today I came across a situation that SQL backup by using script with SQLCMD fails.
Below is the error I got,

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 instance-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 if 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.


image

Why this happens?

Found that it happens when you install SQL Express Edition with a custom Instance Name.

Solution

Editing the properties of Named Pipes will fix this issue, below simple steps will do the tricks

  1. Open SQL Server Configuration Manager and make sure that ‘Named Pipes’ is enabled from the protocols for your instance. Right click on Named Pipes and go to properties.
    image
  2. By default Pipe Name is '\\.\pipe\MSSQL$TOOLS\sql\query' and change the same to '\\.\pipe\sql\query' and click on Apply. image
    Note that its will prompt you to restart the service please restart the service to take affect.
  3. Once service is restarted then try the script, it will work Smile

No comments:

Post a Comment