SqlLocalDB工具的一些有趣發現
阿新 • • 發佈:2020-08-23
本文只是記錄個人使用SqlLocalDB
過程中的一些有趣現象,並不一定適用所有情況。關於SqlLocalDB
工具的具體使用,參見: SQL Server LocalDB 入門 及 SqlLocalDB Utility。
- 當本地安裝多個版本的SQL Server LocalDB時,無法建立低版本的名為
MSSQLLocalDB
的預設例項(注: LocalDB的第一個版本是SQL Server 2012, 預設例項名是v11.0
, 從SQL Server 2014開始,預設例項名修改成了MSSQLLocalDB
), 也無法通過指定Version建立該預設例項。但是不指定Version或者通過SSMS連線(localdb)\MSSQLLocalDB
C:\>SqlLocalDB versions Microsoft SQL Server 2016 (13.1.4001.0) Microsoft SQL Server 2017 (14.0.1000.169) C:\>SqlLocalDB info MSSQLLocalDB ProjectsV13 C:\>SqlLocalDB delete MSSQLLocalDB Delete of LocalDB instance "MSSQLLocalDB" failed because of the following error: The specified LocalDB instance does not exist. C:\>SqlLocalDB create MSSQLLocalDB 13.1 Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error: The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation. C:\>SqlLocalDB create MSSQLLocalDB 13.1.4001.0 Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error: The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation. C:\>SqlLocalDB create MSSQLLocalDB 14.0 Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error: The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation. C:\>SqlLocalDB create MSSQLLocalDB 14.0.1000.169 Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error: The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation. C:\>SqlLocalDB create MSSQLLocalDB LocalDB instance "MSSQLLocalDB" created with version 14.0.1000.169.
- 雖然安裝了多個版本的SQL Server LocalDB, 但是卻不能建立同名例項,試著建立同名例項,返回訊息也不一樣。
C:\>SqlLocalDB create MyDataBase 13.1 LocalDB instance "MyDataBase" created with version 13.1.4001.0. C:\>SqlLocalDB create MyDataBase 14.0 Creation of LocalDB instance "MyDataBase" failed because of the following error: Unable to create the LocalDB instance with specified version. An instance with the same name already exists, but it has lower version than the specified version. C:\>SqlLocalDB create MySQLDB LocalDB instance "MySQLDB" created with version 14.0.1000.169. C:\>SqlLocalDB create MySQLDB 13.1.4001.0 LocalDB instance "MySQLDB" created with version 14.0.1000.169. C:\>SqlLocalDB info MSSQLLocalDB MyDataBase MySQLDB ProjectsV13 C:\>SqlLocalDB info MyDataBase Name: MyDataBase Version: 13.1.4001.0 Shared name: Owner: XXXXXXXXXX Auto-create: No State: Stopped Last start time: 2020/8/23 11:14:50 Instance pipe name: C:\>SqlLocalDB info MySQLDB Name: MySQLDB Version: 14.0.1000.169 Shared name: Owner: XXXXXXXXXX Auto-create: No State: Stopped Last start time: 2020/8/23 11:15:42 Instance pipe name:
- 無意中發現,原來CMD也支援管道,好吧, 認知再一次被重新整理(另: 預設例項
MSSQLLocalDB
的Auto-create
屬性是Yes
, 其他的是No
)!C:\>SqlLocalDB info MSSQLLocalDB | sort Auto-create: Yes Instance pipe name: Last start time: 2020/8/23 10:56:20 Name: MSSQLLocalDB Owner: XXXXXXXXXX Shared name: State: Stopped Version: 14.0.1000.169 C:\>SqlLocalDB info | sort MSSQLLocalDB MyDataBase MySQLDB ProjectsV13