Share via


LocalDB - I keep forgetting

Oh my my...my little brain keeps forgetting the set of commands to play with LocalDB. Today I again forgot so decided that enough is enough. I am going to document them. So as we know, LocalDB was introduced in SQL 2012 with SQL Express (An Express Engine itself who doesn't understand networking with rest all constraints/features as it is). So where is the difference? Well the difference is the benefits of this engine.

  • It doesn't allow you to install same version of LocalDB multiple times on the same machine which means you save lot of space/memory.
  • Also, it switches off when you don't use it. So saves resources as well.
  • It reduces management as you don't have many instances.

So how to go about it? Simple, just select LocalDB while installing SQL Express. But that's it? Well no...now time is to play with it. Different from standard SQL Express engine, by default LocalDB doesn't register a service on registry so you will not see a SQLSrvr.exe running on Task Manager. To start with LocalDB, start with a Command Prompt and browse to your SQL Server Installation directory.

-> CD C:\Program Files\Microsoft SQL Server\110\Tools\Binn

-> You will find SQLLocalDB.exe in the folder. This executable supports many parameters. Common ones are:

  • c - Creates a new instance
  • s - Starts an instance
  • d - Deletes an instance
  • p - Stops an instance
  • i - Lists all instances  
  • There are few other parameters which you may not use but you can access them with /? parameter.

-> Now the biggest problem is how to connect with it. Well the Server Name in Connection String is bit different to connect to LocalDB. Just use (LocalDB)\<instance_name>

That's it. You are connected. Keep in mind that this is Local so you can't connect to this instance from another server. Also, if you don't use this instance for more than 10 minutes, it will switch off automatically. So you need to start it again from above command and "s" parameter. Hope you will enjoy LocalDB and next time I will not forget them ;) Not writing much about LocalDB but if you are interested, let me know. I can write a little more formal post of usage with few screenshots too :)

Comments

  • Anonymous
    May 15, 2014
    very helpful, thanks!