SQL Server LocalDB Management Utility SqlLocalDB.exe
SQL Server LocalDB is a lightweight, easy to use database for application developers.
Microsoft SQL Server LocalDB requires minimum effort for database management so that it enables developers concantrate on application development rather than database administration.
A SQL Server Express LocalDB database is managed by the SqlLocalDB.exe management utility.
In BOL (Books OnLine), you may also read about LocalDBManager.exe management utility, but with Microsoft SQL Server Denali CTP3 release, in Tools folder there was no LocalDBManager.exe binary file.
Probably, this is a documentation error or the LocalDB management utility was changed between documentation and release date.
SQL Server Express LocalDB Management Utility :
Folder : D:\Program Files\Microsoft SQL Server\110\Tools\Binn
File : SqlLocalDB.exe
Developers that use SQL Server LocalDB as database for their application's storage needs can use SqlLocalDB.exe over CMD Windows.
Here in this SQL tutorial developers can find common usage of LocalDB management utility.
Let's start: First open Cmd Windows command prompt
Change your location to "D:\Program Files\Microsoft SQL Server\110\Tools\Binn" SQL Server folder where management executable file is in.
Type "SqlLocalDB -?" for displaying help documentation in order to see available options.
Here is the options available with Denali CTP 3 for application developers that can be used with SQL Server LocalDB management utility.
Microsoft (R) SQL Server Express LocalDB Command Line Tool
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: SqlLocalDB operation [parameters...]
Prints this information
create|c "instance name" [version-number] [-s]
Creates a new Local Database instance with a specified name and version
If the [version-number] parameter is omitted, it defaults to the
SqlLocalDB product version.
-s starts the new Local Database instance after it's created
delete|d "instance name"
Deletes the Local Database instance with the specified name
start|s "instance name"
Starts the Local Database instance with the specified name
stop|p "instance name" [-i|-k]
Stops the Local Database instance with the specified name,
after current queries finish
-i request Local Database instance shutdown with NOWAIT option
-k kills Local Database instance process without contacting it
share|h ["owner SID or account"] "private name" "shared name"
Shares the specified private instance using the specified shared name.
If the user SID or account name is omitted, it defaults to current user.
unshare|u "shared name"
Stops the sharing of the specified shared Local Database instance.
Lists all existing Local Database instances owned by the current user
and all shared Local Database instances.
info|i "instance name"
Prints the information about the specified Local Database instance.
Lists all Local Database versions installed on the computer.
Turns tracing on and off
SqlLocalDB treats spaces as delimiters. It is necessary to surround
instance names that contain spaces and special characters with quotes.
SqlLocalDB create "My LocalDB Instance"
A developer should first create a LocalDB instance using the create option.
Besides "-s" option will start the SQL Server LocalDB instance right after instance creation.
Here is a sample developers can use to create SQL Server Express LocalDB instance MyLocalDB and start the SQL instance directly after it is created.
SqlLocalDB create "MyLocalDB" 11.0 -s
If the SQL Express LocalDB instance is created successfully the following message is returned:
Local database instance "MyLocalDB" created with version 11.0
Local database instance "MyLocalDB" started.
Before creating a localdb instance, it will be better to check all SQL Server LocalDB instances existing on the server by info option as follows:
The return list includes LocalDB instance names besides version information.
It is possible to request instance specific detailed information by passing the SQL Server Express LocalDB instance name to the above info option call.
SqlLocalDB info "MyLocalDB"
As you can see the LocalDB instance specific information includes;
Name : name of the SQL Server Express LocalDB instance,
Version : version of the LocalDB. It is enough to use only the up-to first decimal point in instance create command.
Shared name : if the LocalDB is shared you can see the shared name of the LocalDB instance here,
Owner : Owner of the LocalDB instance or the created by user,
Auto-create : identifies if is set to auto-create,
State : the current state of the SQL Express LocalDB instance,
Last start time : The instance stops automatically after a certain amount of time if there is no activity. Last start time identifies the last time the instance is started.
Instance pipe name : named pipes identifier
After developers complete their programming on database, they can stop and remove the instance from memory.
Just run SqlLocalDB management tool with stop option providing the instance name.
SqlLocalDB stop "MyLocalDB"
If the stop command is successfully executed you will be informed with the following message:
Local Database instance "MyLocalDB" stopped.
Once the SQL Serve Express LocalDB is stopped, you can now remove the SQL instance by delete option.
SqlLocalDB delete "MyLocalDB"
If the delete command is successfull the following command prompt message is returned:
Local Database instance "MyLocalDB" deleted.
Here I tried to summarize the SQL Server LocalDB management utility commands in this SQL tutorial.
These commands are the most important ones to create and start a LocalDB database.
Then developers can stop and remove the LocalDB instance using illustrated LocalDB management tool commands.