設定 user connections 伺服器組態選項Configure the user connections Server Configuration Option

適用於: 是SQL Server 否Azure SQL Database 否Azure Synapse Analytics (SQL DW) 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

此主題描述如何使用 ,在 SQL ServerSQL Server 中設定 SQL Server Management StudioSQL Server Management Studio user connections Transact-SQLTransact-SQL伺服器組態選項。This topic describes how to set the user connections server configuration option in SQL ServerSQL Server by using SQL Server Management StudioSQL Server Management Studio or Transact-SQLTransact-SQL. user connections 選項會指定 SQL ServerSQL Server執行個體上可同時連接的使用者數目上限。The user connections option specifies the maximum number of simultaneous user connections that are allowed on an instance of SQL ServerSQL Server. 實際允許的使用者連接數也取決於您所使用的 SQL ServerSQL Server 版本,以及應用程式的限制或應用程式和硬體的限制而定。The actual number of user connections allowed also depends on the version of SQL ServerSQL Server that you are using, and also the limits of your application or applications and hardware. SQL ServerSQL Server 最多允許 32,767 個使用者連接。allows a maximum of 32,767 user connections. 因為 user connections 是動態的 (自我設定的) 選項,所以 SQL ServerSQL Server 會視需要自動調整最大使用者連接數,最多調整到允許的最大值。Because user connections is a dynamic (self-configuring) option, SQL ServerSQL Server adjusts the maximum number of user connections automatically as needed, up to the maximum value allowable. 例如,如果只有 10 個使用者登入,就配置 10 個使用者連線物件。For example, if only 10 users are logged in, 10 user connection objects are allocated. 在大部分情況下,不需要變更這個選項的值。In most cases, you do not have to change the value for this option. 預設值為 0,表示允許最大量 (32,767) 的使用者連接數。The default is 0, which means that the maximum (32,767) user connections are allowed.

若要判斷系統允許的最大使用者連接數目,您可以執行 sp_configure 或查詢 sys.configuration 目錄檢視。To determine the maximum number of user connections that your system allows, you can execute sp_configure or query the sys.configuration catalog view.

本主題內容In This Topic

開始之前Before You Begin

建議Recommendations

  • 此選項是進階選項,只有具經驗的資料庫管理員或通過認證的 SQL ServerSQL Server 專業人員才可變更。This option is an advanced option and should be changed only by an experienced database administrator or certified SQL ServerSQL Server professional.

  • 使用 user connections 選項有助於避免因並行連接過多,而導致伺服器超過負載。Using the user connections option helps avoid overloading the server with too many concurrent connections. 您可以根據系統與使用者需求估計連接數。You can estimate the number of connections based on system and user requirements. 例如,在有許多使用者的系統上,通常不會每個使用者各要求一個唯一的連接。For example, on a system with many users, each user would not usually require a unique connection. 連接可以由使用者共用。Connections can be shared among users. 執行 OLE DB 應用程式的使用者,對每個開啟的連接物件都必須各有一個連接;執行開放式資料庫連接 (ODBC) 應用程式的使用者,對應用程式中的每個使用中連接控制代碼都必須各有一個連接;而執行 DB-Library 應用程式的使用者,則對呼叫 DB-Library dbopen 函數的每個啟動處理序都必須各有一個連接。Users running OLE DB applications need a connection for each open connection object, users running Open Database Connectivity (ODBC) applications need a connection for each active connection handle in the application, and users running DB-Library applications need one connection for each process started that calls the DB-Library dbopen function.

    重要

    如果必須使用這個選項,請不要將這個值設得太大,因為每個連接不論使用與否,都會造成額外負擔。If you must use this option, do not set the value too high, because each connection has overhead regardless of whether the connection is being used. 如果超過最大使用者連接數,就會收到錯誤訊息,然後要等到可以使用另一個連接後,才能再繼續進行連接。If you exceed the maximum number of user connections, you receive an error message and are not able to connect until another connection becomes available.

安全性Security

權限Permissions

不含參數或只含第一個參數之 sp_configure 上的執行權限預設會授與所有使用者。Execute permissions on sp_configure with no parameters or with only the first parameter are granted to all users by default. 以同時設定兩個參數的 sp_configure 來變更組態選項或執行 RECONFIGURE 陳述式時,使用者必須取得 ALTER SETTINGS 伺服器層級權限。To execute sp_configure with both parameters to change a configuration option or to run the RECONFIGURE statement, a user must be granted the ALTER SETTINGS server-level permission. 系統管理員 (sysadmin)serveradmin 固定伺服器角色會隱含 ALTER SETTINGS 權限。The ALTER SETTINGS permission is implicitly held by the sysadmin and serveradmin fixed server roles.

使用 SQL Server Management StudioUsing SQL Server Management Studio

設定 user connections 選項To configure the user connections option

  1. 在 [物件總管] 中,以滑鼠右鍵按一下伺服器,然後按一下 [屬性]In Object Explorer, right-click a server and click Properties.

  2. 按一下 [連接] 節點。Click the Connections node.

  3. [連接] 下的 [並行連接的最大數目] 方塊中,輸入或選取 0 至 32767 之間的值,以設定可同時連接到 SQL ServerSQL Server執行個體的最大使用者數目。Under Connections, in the Max number of concurrent connections box, type or select a value from 0 through 32767 to set the maximum number of users that are allowed to connect simultaneously to the instance of SQL ServerSQL Server.

  4. 重新啟動 SQL ServerSQL ServerRestart SQL ServerSQL Server.

使用 Transact-SQLUsing Transact-SQL

設定 user connections 選項To configure the user connections option

  1. 連接到 Database EngineDatabase EngineConnect to the Database EngineDatabase Engine.

  2. 在標準列中,按一下 [新增查詢]From the Standard bar, click New Query.

  3. 複製下列範例並將其貼到查詢視窗中,然後按一下 [執行]Copy and paste the following example into the query window and click Execute. 此範例示範如何使用 sp_configure 以將 user connections 選項的值設定為 325 位使用者。This example shows how to use sp_configure to configure the value of the user connections option to 325 users.

USE AdventureWorks2012 ;  
GO  
EXEC sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE ;  
GO  
EXEC sp_configure 'user connections', 325 ;  
GO  
RECONFIGURE;  
GO  
  

如需詳細資訊,請參閱 伺服器設定選項 (SQL Server)伺服器組態選項。For more information, see Server Configuration Options (SQL Server).

後續操作:設定使用者連線選項之後Follow Up: After you configure the user connections option

伺服器必須重新啟動之後,設定才能生效。The server must be restarted before the setting can take effect.

另請參閱See Also

RECONFIGURE (Transact-SQL) RECONFIGURE (Transact-SQL)
伺服器組態選項 (SQL Server) Server Configuration Options (SQL Server)
sp_configure (Transact-SQL)sp_configure (Transact-SQL)