Jesse Johnston
.NET Dev. Good times with .NET and coffee

Using SQL Server 2008 Express as a default instance

Saturday, 13 September 2008 17:46 by jesse

Time to upgrade!  After uninstalling SQL Server 2005, I decided that I would try running only the Express version of SQL Server 2008 on my laptop.  After installing, I found that running SQLCMD against the (local) server no longer worked.  For example,

sqlcmd -s (local) -i SomeScript.sql

Resulted in this error:

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.

I had installed SQL Server 2008 Express as the default instance (and I don't have any other version of SQL Server on this machine), and accepted the default instance name SQLEXPRESS.

SQLCMD is connecting to the instance through named pipes, and the pipe name it connects on for the default instance is \\.\pipe\sql\query

To connect to a named instance, it connects through the named pipe \\.\pipe\MSSQL$<instancename>\sql\query

Sure enough, after opening Sql Server Configuration Manager, I expanded the Sql Server Network Configuration, double-clicked on Named Pipes, and was able to see that the pipe name included the instance name SQLEXPRESS.  After changing the pipe name to \\.\pipe\sql\query, my sqlcmd reference to (local) worked great.  Whew.

Named Pipes Properties

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Tags:  
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (2) | Comment RSSRSS comment feed

Comments

March 19. 2009 21:13

pingback

Pingback from digitalformula.net

SQLCMD.EXE on SQL 2008 doesn’t work - HResult 0×2, Level 16, State 1 » Digital Formula

digitalformula.net

May 16. 2009 14:37

pingback

Pingback from blog.mclaughlinsoftware.com

How to get sqlcmd.exe to work for SQL Server 2008 Express Edition | MacLochlainns Weblog

blog.mclaughlinsoftware.com

Comments are closed