Connect to LocalDB via SQL Server Management Studio

If you are like me (then you need help!) you probably don’t like much using Visual Studio to talk to an instance of LocalDB. For the uninitated here is the definition of LocalDB shamelessly poached from MSDN

“LocalDB is an execution mode of SQL Server Express targeted to program developers. LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, developers initiate a connection by using a special connection string. When connecting, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex or time consuming configuration tasks.”

It turns out there is a way to connect to LocalDB instance using traditional SQL Server Management Studio although it is not quite straightforward and intuitive. In this post I briefly explain how you can gain some control of LocalDB instances and manage them using SQL Server Management Studio.

Enter SqlLocalDB.exe

SqlLocalDB.exe is a tool provided by Microsoft that can be used to manage the instances of LocalDB on your box. This tool is usually at C:\Program Files\Microsoft SQL Server\{ver}\Tools\Binn location where {ver} references to the version of SQL Server you are using.

So navigate to the location above and fire this command

SqlLocalDB -info

You will notice an output like this

C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe i
MSSQLLocalDB
ProjectsV12
v11.0

The above are the instances of LocalDB that I have running on my machine. Next I select one instance and again fire the info command

C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe i ProjectsV12
Name: ProjectsV12
Version: 12.0.2000.8
Shared name:
Owner: FIREBALL\Nik Gupta
Auto-create: No
State: Stopped
Last start time: 09-Dec-15 2:38:45 PM
Instance pipe name:

As you can notice on my machine named FIREBALL (I told you I need help) this particular instance is stopped. So let us start it.

C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe start ProjectsV12
LocalDB instance "ProjectsV12" started.

Now with the instance started if I run the info command again I get a value for the “Instance pipe name” property (highlighted below)

C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe i ProjectsV12
Name: ProjectsV12
Version: 12.0.2000.8
Shared name:
Owner: FIREBALL\Nik Gupta
Auto-create: No
State: Running
Last start time: 10-Dec-15 9:47:12 AM
Instance pipe name: np:\\.\pipe\LOCALDB#E81A1F33\tsql\query

Simply copy this value and paste it in the SQL Server Management Studio’s “Server Name” property

SQL Server LocalDB Connection
Connect to LocalDB via SQL Server Management Studio

And that’s it. Happy coding!

Leave a Comment

Your email address will not be published.

8 Trackbacks