星期二, 8月 15, 2023

[SQL] 別名

在本機安裝 SQL Server 時,都習慣會 [自訂 instance name] 而不使用 [預設 instance name],使用 SSMS 連線時就必須使用 [.\自訂 InsanceName],想要使用 [.] 直接進行連線的話,必須依賴別名功能

When connecting to SQL Server running on the same computer as the client, you can use (local) as the server name. This is not encouraged as it leads to ambiguity, however it can be useful when the client is known to be running on the intended computer. For instance, when creating an application for mobile disconnected users, such as a sales force, where SQL Server will run on laptop computers and store project data, a client connecting to (local) would always connect to the SQL Server running on the laptop. The word localhost or a period (.) can be used in place of (local).
By default, SQL Server connects to a local instance of SQL Server using the Shared Memory protocol, and to an instance of SQL Server on another computer using either TCP/IP or Named Pipes. Create an alias when you are using TCP/IP or named pipes, and you want to provide a customized connection string, or when you want to use a name other than the server name for the connection.
別名是 SQL Native Client 功能,有區分 32 bit 和 64 bit,SSMS V19.1 是 32bit,所以只要設定 SQL Native Client 11.0 組態 (32 位元) 就行,設定路徑為 SQL Server 組態管理員 (Configuration Manager) => SQL Native Client 11.0 組態 (32 位元) => 別名

新增別名 => 輸入相關設定

沒有留言:

張貼留言