SqlLocalDB 公用程式

SqlLocalDB / multiple versions

語法: 
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     | -? ]  
}  


--Version
C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqllocaldb versions
Microsoft SQL Server 2016 (13.0.6300.2)
Microsoft SQL Server 2019 (15.0.2000.5)

-- list instances 
C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqllocaldb info
MSSQLLocalDB
TestInst

--Create Instance
Latest Version
C:\>sqllocaldb create MyNewInstance
LocalDB instance "MyNewInstance" created with version 13.0.1100.286.


--Create instance with specific Version
C:\>sqllocaldb create Myinst2 13.0.6300.2
LocalDB instance "MyNewInstance12" created with version 12.0.2000.8.

C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqllocaldb create Myinst2 13.0.6300.2
LocalDB instance "Myinst2" created with version 13.0.6300.2.

C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqllocaldb info Myinst2
Name:               Myinst2
Version:            13.0.6300.2
Shared name:
Owner:              SQL6\Administrator
Auto-create:        No
State:              Stopped
Last start time:    7/12/2022 10:17:40 PM
Instance pipe name:

C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqllocaldb start Myinst2
LocalDB instance "Myinst2" started.

C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqllocaldb info Myinst2
Name:               Myinst2
Version:            13.0.6300.2
Shared name:
Owner:              SQL6\Administrator
Auto-create:        No
State:              Running
Last start time:    7/12/2022 10:21:21 PM
Instance pipe name: np:\\.\pipe\LOCALDB#27EA918F\tsql\query

C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqlcmd -S np:\\.\pipe\LOCALDB#27EA918F\tsql\query
1> select @@version;
2> go
                                                                                                                                                                                       
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2016 (SP3) (KB5003279) - 13.0.6300.2 (X64)
       Aug  7 2021 01:20:37
       Copyright (c) Microsoft Corporation
       Express Edition (64-bit) on Windows Server 2019 Standard 10.0 <X64> (Build 17763: ) (Hypervisor)

 

SQL Server Express LocalDB
https://docs.microsoft.com/zh-tw/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-ver16

SqlLocalDB 公用程式
https://docs.microsoft.com/zh-tw/sql/tools/sqllocaldb-utility?view=sql-server-ver16