SqlLocalDB Utility

Use the SqlLocalDB utility to create an instance of Microsoft SQL Server 2016 ExpressLocalDB. The SqlLocalDB utility (SqlLocalDB.exe) is a simple command line tool to enable users and developers to create and manage an instance of SQL Server ExpressLocalDB. For information about how to use LocalDB, see SQL Server 2016 Express LocalDB.


      [ 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     | -? ]  


[ create | c ] <instance-name> <instance-version> [-s ]
Creates a new of instance of SQL Server ExpressLocalDB. SqlLocalDB uses the version of SQL Server Express 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.

[ share | h ]
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.

[ unshared | u ]
Stops the sharing of the specified shared instance of LocalDB.

[ delete | d ] <instance-name>
Deletes the specified instance of SQL Server ExpressLocalDB.

[ start | s ] "<instance-name>"
Starts the specified instance of SQL Server ExpressLocalDB. When successful the statement returns the named pipe address of the LocalDB.

[ stop | p ] <instance-name> [-i ] [-k ]
Stops the specified instance of SQL Server ExpressLocalDB. Adding –i requests the instance shutdown with the NOWAIT option. Adding –k kills the instance process without contacting it.

[ info | i ] [ <instance-name> ]
Lists all instance of SQL Server ExpressLocalDB owned by the current user.

<instance-name> returns the name, version, state (Running or Stopped), last start time for the specified instance of SQL Server ExpressLocalDB, and the local pipe name of the LocalDB.

[ trace | t ] on | off
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 SQL Server 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 currently logged in user. An SQLLOCALDB Instance, when shared, can only be started and stopped by the owner of the instance.


A. Creating an Instance of LocalDB

The following example creates an instance of SQL Server ExpressLocalDB named DEPARTMENT using the SQL Server 2016 binaries and starts the instance.

SqlLocalDB.exe create "DEPARTMENT" 12.0 -s  

B. Working with a Shared Instance of LocalDB

Open a command prompt using Administrator privileges.

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 = 'Passw0rd!!@52';   

Execute the following code to connect to the shared instance of LocalDB using the NewLogin login.

sqlcmd –S (localdb)\.\DeptSharedLocalDB -U NewLogin -P Passw0rd!!@52  

See Also

SQL Server 2016 Express LocalDB
Command-Line Management Tool: SqlLocalDB.exe