How to get your developer workstation Microsoft SQL Server Express LocalDB-ready

Microsoft SQL Server Express LocalDB, a solution primarily intended for developers, is a lightweight version of SQL Server Express. It is very easy to install and set up.
The installation copies a minimum set of files which are necessary to start SQL Server Database Engine. LocalDB supports the same T-SQL language and has the same limitations as SQL Server Express.

Microsoft SQL Server Express LocalDB allows developers to write and test Transact-SQL code. But, without having to manage a full server instance of SQL Server.

There are several methods of installing LocalDB. Since i usually use LocalDB in combination with Visual Studio, i only cover the installation of localDB with the Visual Studio Installer.

Once the Visual Studio Installed has been downloaded and started, sleect .NET desktop development -> then check the checkbox to the right, to make sure the Installer also installs SQL Server Express 2016 LocalDB

Visual Studio Installer – SQL Server Express 2016 LocalDB

Once the installation is complete (or during the installation), i usually install SQL Server Management Studio using Chocolatey.

To get Chocolatey installed, just fire-up a PowerShell Instance (elevated, as admin!) and type:

Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Install Chocolatey

Now since we have working Chocolatey environment, we can use the following command to download and install SQL Server Management Studio (SSMS).

choco install ssms

or

choco install sql-server-management-studio
SQL Server Management Studio (SSMS) Installation using Chocolatey

Now if you start SQL Server Management Studio (SSMS) and try to connect to the LocalDB instance -> (localdb)\MSSQLLocalDB , you’ll most probably get the following error message:

SSMS – LocalDB Instance connect, worth a try

Cannot connect to (localdb)\mssqllocaldb.

ADDITIONAL INFORMATION:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 – Local Database Runtime error occurred. Error occurred during LocalDB instance startup: SQL Server process failed to start.
) (Microsoft SQL Server, Error: -1983577846)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=-1983577846&LinkId=20476


We will fix that in the next post