Friday, October 13, 2023

Using LocalDB in 3 Steps

Problem: While doing a demo on a client’s PC that didn’t have SQL Server Developer Edition installed, I needed a quick way to demonstrate querying a SQL Server DB without installing SQL Server.

 

Solution: LocalDB to the rescue!  The client’s PC did have SQL Server Management Studio installed, along with SQL Server Express.  This gave me enough capability to create a sample DB and demonstrate how to query it.

 

To create a DB instance:

  1. Open a Command Prompt window
  2. Enter “sqllocaldb create “Ch1Demo” “, where Ch1Demo was the specific name of my DB instance.  This short command quickly created an instance using the default version of the SQL Server DB Engine installed (see below).  This process was nearly instant (see below).

 

 

Since my username is “Sam”, The DB was created in the path C:\Users\Sam\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\Ch1Demo

 

  1. To connect to the DB instance, simply use SQL Server Management Studio with the Server Name preceded with “(localdb)\”

 

 

For all intents and purposes, Ch1Demo will appear as any other DB instance, allowing DB creation, updates, and queries.

 

 

This was the perfect solution in a pinch, and it helps you as well.

 

To learn more about localDB, visit https://learn.microsoft.com/en-us/sql/tools/sqllocaldb-utility?view=sql-server-ver16

 

No comments:

Post a Comment