sys.dm_tcp_listener_states (Transact-SQL)sys.dm_tcp_listener_states (Transact-SQL)

適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions)

針對每個 TCP 接聽程式傳回一個包含動態狀態資訊的資料列。Returns a row containing dynamic-state information for each TCP listener.

注意

可用性群組接聽程式可能會接聽與 SQL ServerSQL Server 執行個體的接聽程式相同的通訊埠。The availability group listener could listen to the same port as the listener of the instance of SQL ServerSQL Server. 在此情況下,接聽程式會個別列出,與 Service Broker 接聽程式一樣。In this case, the listeners are listed separately, the same as for a Service Broker listener.

資料行名稱Column name 資料類型Data type 描述Description
listener_idlistener_id intint 接聽程式的內部識別碼。Listener's internal ID. 不可為 Null。Is not nullable.

主索引鍵。Primary key.
ip_addressip_address Nvarchar (48)nvarchar(48) 目前在線上而且正在接聽的接聽程式 IP 位址。The listener IP address that is online and currently being listening to. 允許 IPv4 和 IPv6。Either IPv4 and IPv6 is allowed. 如果接聽程式擁有這兩種位址,則會個別列出。If a listener possesses both types of addresses, they are listed separately. IPv4 萬用字元會顯示為 "0.0.0.0"。An IPv4 wildcard, is displayed as "0.0.0.0". IPv6 萬用字元會顯示為 "::"。An IPv6 wildcard, is displayed as "::".

不可為 Null。Is not nullable.
is_ipv4is_ipv4 bitbit IP 位址的類型Type of IP address

1 = IPv41 = IPv4

0 = IPv60 = IPv6
portport intint 接聽程式正在接聽的通訊埠編號。The port number on which the listener is listening. 不可為 Null。Is not nullable.
typetype tinyinttinyint 接聽程式類型,下列其中一個值:Listener type, one of:

0 = Transact-SQLTransact-SQL0 = Transact-SQLTransact-SQL

1 = Service Broker1 = Service Broker

2 = 資料庫鏡像2 = Database mirroring

不可為 Null。Is not nullable.
type_desctype_desc Nvarchar (20)nvarchar(20) 類型 的描述,下列其中一個:Description of the type, one of:

TSQLTSQL

SERVICE_BROKERSERVICE_BROKER

DATABASE_MIRRORINGDATABASE_MIRRORING

不可為 Null。Is not nullable.
statestate tinyinttinyint 可用性群組接聽程式的狀態,可為下列其中一個值:State of the availability group listener, one of:

1 = 線上。1 = Online. 接聽程式正在接聽和處理要求。The listener is listening and processing requests.

2 = 暫止重新啟動。2 = Pending restart. 接聽程式離線,暫止重新啟動。the listener is offline, pending a restart.

如果可用性群組接聽程式正在接聽與伺服器執行個體相同的通訊埠,這兩個接聽程式一定會擁有相同的狀態。If the availability group listener is listening to the same port as the server instance, these two listeners always have the same state.

不可為 Null。Is not nullable.

注意:此資料行中的值來自 TSD_listener 物件。Note: The values in this column come from the TSD_listener object. 此資料行不支援離線狀態,因為當 TDS_listener 離線時,無法查詢其狀態。The column does not support an offline state because when the TDS_listener is offline, it cannot be queried for state.
state_descstate_desc Nvarchar (16)nvarchar(16) 狀態 的描述,下列其中一個:Description of state, one of:

ONLINEONLINE

PENDING_RESTARTPENDING_RESTART

不可為 Null。Is not nullable.
start_timestart_time datetimedatetime 指出何時已啟動接聽程式的時間戳記。Timestamp indicating when the listener was started. 不可為 Null。Is not nullable.

安全性Security

權限Permissions

需要伺服器的 VIEW SERVER STATE 權限。Requires VIEW SERVER STATE permission on the server.

另請參閱See Also

查詢 SQL Server 系統目錄常見問題 Querying the SQL Server System Catalog FAQ
AlwaysOn 可用性群組目錄檢視 (Transact-SQL) Always On Availability Groups Catalog Views (Transact-SQL)
AlwaysOn 可用性群組動態管理檢視和函式 (Transact-SQL)Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL)