Starting LocalDB–#SQLNewBlogger

Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

Lots of people have never worked with LocalDB, which is an in-process version of SQL Express. No service account, just a SQL Server instance running with your app. It’s a nice lightweight way to get SQL Server running quickly without a hassle.

This is a SQL Server Express version, but the bare bones for development. This post looks at how you can get this running.

This version of SQL is installed with SQL Express, and with Visual Studio. If you look in this path: C:\Program Files\Microsoft SQL Server\150\Tools\Binn, there is a SQLLocalDB.exe. You can see that here.

2022-03-03 09_08_00-Binn

This is my SQL Server 2016 version of LocalDB. I can start a new instance by calling this with the CREATE option. I can give this a name as well, as I might want to stat multiple instance for different apps. Here I’ll create an instance called app1.

SQLLocalDB create app1

I then call the same command, but use START instead of CREATE. You can see this reports as started from the CLI. I also add the INFO call to get status.

2022-03-03 09_10_35-C__Windows_System32_cmd.exe

Now I can connect. I use (LocalDB)\app1 to connect:

2022-03-03 09_11_39-Connect to Database Engine

I see I’m connected to a version of LocalDB then:

2022-03-03 09_12_03-SQLQuery2.sql - (localdb)_app1.master (ARISTOTLE_Steve (70))_ - Microsoft SQL Se

Now it’s just an instance of SQL Server I can use.

 

SQL New Blogger

I needed to check something for a customer and realized I hadn’t started LocalDB in a long time, so I needed to check the docs. I spent 10 minutes putting this post together.

An easy type of post for any of you out there. Learn something, try something, write something.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , , . Bookmark the permalink.

2 Responses to Starting LocalDB–#SQLNewBlogger

  1. Jeff Moden says:

    Is “LocalDB” the name for what used to be known as the “Compact Edition”? The abbreviation for that was “CE”, which we pronounced as “Crippled Edition” because it is SERIOUSLY crippled compared to SQL Express.

    Like

    • way0utwest says:

      Compact Edition was designed to be on mobile or small devices, so it wasn’t supposed to be close to Express. This was designed to be embedded database for apps and semi-transient storage that would sync to a larger, normal SQL Server database. Essentially bringing ACID to transactions instead of writing them to a text file of some sort and then ETL’ing them up.

      I thought this was a separate process running on a mobile device, but I cannot be sure.

      LocalDB is Express, but running in process. Meaning that if I start an app (single process), this same thread starts up the db and runs it. Think of this as if I embedded the SQL Server code into my app and then compiled it all together. My app runs, I have a SQL Server db. My app stops, I have no DB.

      LocalDB instances can be created, and essentially run in process with no service account or other infrastructure provided. It was really meant to be an instance installed with and running under Visual Studio. Now it’s semi independent, but again, no service account, so really a lightweight dev/test instance of SQL without doing any of the SQL Server setup or configuration.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.