Overview - egnomerator/misc GitHub Wiki

SQL Server 2016 LocalDB

A good starting point for research: SQL Server 2016 Express LocalDB

Information

What is LocalDB

  • it's a SQL Server Express feature targeted to developers
  • minimal set of files necessary to start the SQL Server Database Engine
  • provides database implementation without the overhead of managing a full SQL Server instance

Restrictions

LocalDB cannot be a merge replication subscriber.

LocalDB does not support FILESTREAM.

LocalDB only allows local queues for Service Broker.

An instance of LocalDB owned by the built-in accounts such as NT AUTHORITY\SYSTEM can have manageability issues due to windows file system redirection; Instead use a normal windows account as the owner.

Automatic and Named Instances

Automatic instances

  • public on the machine
  • one instance per machine
  • easy maintenance and connectivity (it's automatic)
  • as long as any given machine has an automatic instance installed, an application designed to use it will be able to seamlessly connect on any of these machines
  • special pattern for the instance name that belongs to a reserved namespace Named instances
  • private instances
  • owned by a single app which is responsible for creating and maintaining the instance
  • can be created via the LocaDB management API or via the app's app.config file

Getting Started

Installation

FIRST: Check whether it is already installed

  • in CMD or PowerShell type sqllocaldb versions and see if the 2016 version is already installed (see example output below in the "Some helpful commands" section)
  • it might already be installed due to having installed it along with some other SQL Server or Visual Studio software in the past

Installation

  • Get the installer file SQLServer2016-SSEI-Expr.exe
  • Run that file, choose "Download Media" > LocalDB
  • Click Download
  • Just run the installer which hardly takes any time
  • Done!

Some helpful commands

View the LocalDB man page

C:\>sqllocaldb
Microsoft (R) SQL Server Express LocalDB Command Line Tool
Version 11.0.2100.60
Copyright (c) Microsoft Corporation.  All rights reserved.

Usage: SqlLocalDB operation [parameters...]

# more output not included in this text snippet ...

View all installed LocalDB versions on the machine

C:\>sqllocaldb versions
Microsoft SQL Server 2012 (11.0.2100.60)
Microsoft SQL Server 2014 (12.0.2000.8)
Microsoft SQL Server 2016 (13.0.1601.5)

View all existing LocalDB instances on the machine

C:\>sqllocaldb info
MSSQLLocalDB
ProjectsV13
v11.0

View info on a specific instance

C:\>sqllocaldb info v11.0
Name:               v11.0
Version:            11.0.2100.60
Shared name:
Owner:              machine\user
Auto-create:        Yes
State:              Stopped
Last start time:    2/23/2018 6:05:18 PM
Instance pipe name:

When attempting to view info on one of my specific instances, I got this output

C:\>sqllocaldb info MSSQLLocalDB
The required LocalDB version "0.0" is not installed.

I ran tried starting the instance, and it successfully started, and then I was able to view info on that instance.

  • I don't know why that fixed the issue, but this is why I decided to try starting the instance

This is how to start an instance

C:\>sqllocaldb start MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" started.

LocalDB via SSMS

Connecting

There is a pattern for designating a LocalDB instance:

(localdb)\<instance name>

So, to connect to a running instance, MSSQLLocalDB for example, via SSMS type this for the server name:

(localdb)\MSSQLLocalDB

And use Windows Authentication

⚠️ **GitHub.com Fallback** ⚠️