| title | SqlLocalDB Utility | |||
|---|---|---|---|---|
| description | The SqlLocalDB utility command line tool allows users and developers to create and manage an instance of SQL Server Express LocalDB. | |||
| author | rwestMSFT | |||
| ms.author | randolphwest | |||
| ms.date | 12/16/2025 | |||
| ms.service | sql | |||
| ms.subservice | tools-other | |||
| ms.topic | concept-article | |||
| ms.collection |
|
|||
| helpviewer_keywords |
|
[!INCLUDE sqlserver]
Use the SqlLocalDB utility to create an instance of [!INCLUDE ssExpress] LocalDB. The SqlLocalDB utility (SqlLocalDB.exe) is a command line tool to enable users and developers to create and manage an instance of [!INCLUDE ssExpress] LocalDB. For information about how to use LocalDB, see SQL Server Express LocalDB.
SqlLocalDB.exe
{
[ create | c ] <instance-name> <instance-version> [ -s ]
| [ delete | d ] <instance-name>
| [ start | s ] <instance-name>
| [ stop | p ] <instance-name> [ -i ] [ -k ]
| [ share | h ] [ "<user_SID>" | "<user_account>" ] "<private-name>" "<shared-name>"
| [ unshare | u ] "<shared-name>"
| [ info | i ] <instance-name>
| [ versions | v ]
| [ trace | t ] [ on | off ]
| [ help | -? ]
}Creates a new of instance of [!INCLUDE ssExpress] LocalDB. SqlLocalDB uses the version of [!INCLUDE ssExpress] binaries specified by <instance-version> argument. The version number is specified in numeric format with at least one decimal. The minor version numbers (service packs) are optional. For example the following two version numbers are both acceptable: 11.0, or 11.0.1186. The specified version must be installed on the computer. If not specified, the version number defaults to the version of the SqlLocalDB utility. Adding -s starts the new instance of LocalDB.
Shares the specified private instance of LocalDB using the specified shared name. If the user SID or account name is omitted, it defaults to the current user.
Stops the sharing of the specified shared instance of LocalDB.
Deletes the specified instance of [!INCLUDE ssExpress] LocalDB.
Starts the specified instance of [!INCLUDE ssExpress] LocalDB. When successful the statement returns the named pipe address of the LocalDB.
Stops the specified instance of [!INCLUDE ssExpress] LocalDB. Adding -i requests the instance shutdown with the NOWAIT option. Adding -k kills the instance process without contacting it.
Lists all instance of [!INCLUDE ssExpress] LocalDB owned by the current user.
<instance-name> returns the name, version, state (Running or Stopped), last start time for the specified instance of [!INCLUDE ssExpress] LocalDB, and the local pipe name of the LocalDB.
trace on enables tracing for the SqlLocalDB API calls for the current user. trace off disables tracing.
Returns brief descriptions of each SqlLocalDB option.
The instance name argument must follow the rules for [!INCLUDE ssNoVersion] identifiers or it must be enclosed in double quotes.
Executing SqlLocalDB without arguments returns the help text.
Operations other than start can only be performed on an instance belonging to the currently signed-in user. A SQLLOCALDB instance, when shared, can only be started and stopped by the owner of the instance.
The following example creates an instance of [!INCLUDE ssExpress] LocalDB named DEPARTMENT using the [!INCLUDE ssnoversion] binaries and starts the instance.
SqlLocalDB.exe create "DEPARTMENT" 12.0 -sOpen a command prompt using Administrator privileges. Replace <password> with a valid password.
SqlLocalDB.exe create "DeptLocalDB"
SqlLocalDB.exe share "DeptLocalDB" "DeptSharedLocalDB"
SqlLocalDB.exe start "DeptLocalDB"
SqlLocalDB.exe info "DeptLocalDB"
REM The previous statement outputs the Instance pipe name for the next step
sqlcmd -S np:\\.\pipe\LOCALDB#<use your pipe name>\tsql\query
CREATE LOGIN NewLogin WITH PASSWORD = '<password>';
GO
CREATE USER NewLogin;
GO
EXITExecute the following code to connect to the shared instance of LocalDB using the NewLogin login. Replace <password> with a valid password.
sqlcmd -S (localdb)\.\DeptSharedLocalDB -U NewLogin -P <password>