選擇網路通訊協定Choosing a Network Protocol

若要連接到 SQL Server Database EngineSQL Server Database Engine ,必須啟用網路通訊協定。To connect to SQL Server Database EngineSQL Server Database Engine you must have a network protocol enabled. MicrosoftMicrosoft [SQL Server]SQL Server 可以同時處理多個通訊協定的要求。 [SQL Server]SQL Server can service requests on several protocols at the same time. 用戶端會使用單一通訊協定連接到 [SQL Server]SQL ServerClients connect to [SQL Server]SQL Server with a single protocol. 如果用戶端程式不知道 [SQL Server]SQL Server 正在接聽哪個通訊協定,請設定用戶端循序嘗試多個通訊協定。If the client program does not know which protocol [SQL Server]SQL Server is listening on, configure the client to sequentially try multiple protocols. 您可以使用 [SQL Server]SQL Server 組態管理員來啟用、停用及設定網路通訊協定。Use [SQL Server]SQL Server Configuration Manager to enable, disable, and configure network protocols.

共用記憶體Shared Memory

共用記憶體是使用上最簡單的通訊協定,而且不用設定任何設定。Shared memory is the simplest protocol to use and has no configurable settings. 因為使用共用記憶體通訊協定的用戶端,只能連接到在相同電腦上執行的 [SQL Server]SQL Server 執行個體,所以不適用於大部分資料庫活動。Because clients using the shared memory protocol can only connect to a [SQL Server]SQL Server instance running on the same computer, it is not useful for most database activity. 當您懷疑其他通訊協定的設定不正確時,請使用共用記憶體通訊協定進行疑難排解。Use the shared memory protocol for troubleshooting when you suspect the other protocols are configured incorrectly.

注意

使用 MDAC 2.8 或舊版的用戶端無法使用共用記憶體通訊協定。Clients that use MDAC 2.8 or earlier cannot use shared memory protocol. 即使這些使用者嘗試使用此通訊協定,還是會自動切換成具名管道通訊協定。If these clients try this, they are automatically switched to the named pipes protocol.

TCP/IPTCP/IP

TCP/IP 是網際網路廣泛使用的一般通訊協定。TCP/IP is a common protocol widely used over the Internet. 其可在具有各種硬體架構與不同作業系統之電腦的互連網路間通訊。It communicates across interconnected networks of computers that have diverse hardware architectures and various operating systems. TCP/IP 包括了路由網路傳輸量的標準,同時提供了進階安全性功能,TCP/IP includes standards for routing network traffic and offers advanced security features. 為現今企業中最常用的通訊協定。It is the most popular protocol that is used in business today. 設定電腦使用 TCP/IP 是一件很複雜的作業,但大部分網路電腦都已正確完成設定。Configuring your computer to use TCP/IP can be complex, but most networked computers are already correctly configured. 若要設定「 [SQL Server]SQL Server 組態管理員」中未公開的 TCP/IP 設定,請參閱 MicrosoftMicrosoft Windows 文件集。To configure the TCP/IP settings that are not exposed in [SQL Server]SQL Server Configuration Manager, see the MicrosoftMicrosoft Windows documentation.

具名管道Named Pipes

「具名管道」是為區域網路開發的通訊協定。Named Pipes is a protocol developed for local area networks. 有一個處理序會使用部分記憶體將資訊傳遞給另一個處理序,如此該處理序的輸出會是另一個處理序的輸入。A part of memory is used by one process to pass information to another process, so that the output of one is the input of the other. 第二個處理序可以在本機 (跟第一個處理序位於相同的電腦上) 或位於遠端 (在網路電腦上)。The second process can be local (on the same computer as the first) or remote (on a networked computer).

具名管道與TCP/IP 通訊端Named Pipes vs. TCP/IP Sockets

在速度快的區域網路 (LAN) 環境中,傳輸控制通訊協定/網際網路通訊協定 (TCP/IP) 通訊端與具名管道用戶端在效能方面可相互媲美。In a fast local area network (LAN) environment, Transmission Control Protocol/Internet Protocol (TCP/IP) Sockets and Named Pipes clients are comparable with regard to performance. 但是,若使用速度較慢的網路,例如,廣域網路 (WAN) 或撥號網路,TCP/IP 通訊端與具名管道用戶端之間,在效能上的差異就顯而易見。However, the performance difference between the TCP/IP Sockets and Named Pipes clients becomes apparent with slower networks, such as across wide area networks (WANs) or dial-up networks. 這是因為跨處理序通訊 (IPC) 機制,在對等端之間通訊的方式不同。This is because of the different ways the interprocess communication (IPC) mechanisms communicate between peers.

對於具名管道,網路通訊一般較為互動。For named pipes, network communications are typically more interactive. 對等會等到另一個對等使用讀取命令,要求傳送資料時才會傳送。A peer does not send data until another peer asks for it using a read command. 網路讀取動作在開始讀取資料之前,一般會涉及一連串的對等具名管道訊息。A network read typically involves a series of peek named pipes messages before it starts to read the data. 這些在速度慢的網路中要付出的成本可能相當昂貴,而且會導致產生過多的網路傳輸量,而影響到其他網路用戶端。These can be very costly in a slow network and cause excessive network traffic, which in turn affects other network clients.

釐清您正在討論的是本機管道或網路管道也很重要。It is also important to clarify if you are talking about local pipes or network pipes. 如果在執行 [SQL Server]SQL Server執行個體的電腦本機執行伺服器應用程式,則可以選擇本機的具名管道通訊協定。If the server application is running locally on the computer that is running an instance of [SQL Server]SQL Server, the local Named Pipes protocol is an option. 本機的具名管道會在核心模式下執行且執行速度會相當快。Local named pipes runs in kernel mode and is very fast.

對於 TCP/IP 通訊端,資料傳輸較為簡化而且負擔較輕。For TCP/IP Sockets, data transmissions are more streamlined and have less overhead. 資料傳輸也可以得利於 TCP/IP 通訊端效能增強機制 (例如,視窗型、延遲的收條等等),Data transmissions can also take advantage of TCP/IP Sockets performance enhancement mechanisms such as windowing, delayed acknowledgements, and so on. 這對速度慢的網路非常有幫助。This can be very helpful in a slow network. 視應用程式類型而定,效能差異可能十分顯著。Depending on the type of applications, such performance differences can be significant.

TCP/IP 通訊端也支援積存佇列,TCP/IP Sockets also support a backlog queue. 跟在嘗試連接到 [SQL Server]SQL Server時可能會導致管道忙碌而產生錯誤的具名管道相比,可提供一些緩衝效果。This can provide a limited smoothing effect compared to named pipes that could lead to pipe-busy errors when you are trying to connect to [SQL Server]SQL Server.

一般來說,速度慢的 LAN、WAN 或撥接網路會偏好使用 TCP/IP,而當不用擔心網路速度時,具名管道會是較佳的選擇,因為提供的功能較多、操作更為簡單,而且組態選項較多。Generally, TCP/IP is preferred in a slow LAN, WAN, or dial-up network, whereas named pipes can be a better choice when network speed is not the issue, as it offers more functionality, ease of use, and configuration options.

啟用通訊協定Enabling the Protocol

用戶端與伺服器兩者必須都啟用通訊協定,才能夠運作。The protocol must be enabled on both the client and server to work. 伺服器可以同時接聽來自所有已啟用之通訊協定上的要求。The server can listen for requests on all enabled protocols at the same time. 用戶端電腦可挑選一個通訊協定,或按 [SQL Server]SQL Server 組態管理員中列出的通訊協定依序嘗試。Client computers can pick one, or try the protocols in the order listed in [SQL Server]SQL Server Configuration Manager.

如需如何設定通訊協定並連接到 Database EngineDatabase Engine的簡要教學課程,請參閱 教學課程:Database Engine 使用者入門For a short tutorial about how to configure protocols and connect to the Database EngineDatabase Engine, see Tutorial: Getting Started with the Database Engine.