共用方式為


ServerConnection.ProcessID 屬性

Gets the ID value that uniquely identifies the process associated with the referenced connection to the server.

命名空間:  Microsoft.SqlServer.Management.Common
組件:  Microsoft.SqlServer.ConnectionInfo (在 Microsoft.SqlServer.ConnectionInfo.dll 中)

語法

'宣告
Public ReadOnly Property ProcessID As Integer 
    Get
'用途
Dim instance As ServerConnection 
Dim value As Integer 

value = instance.ProcessID
public int ProcessID { get; }
public:
property int ProcessID {
    int get ();
}
member ProcessID : int
function get ProcessID () : int

屬性值

型別:System.Int32
An Int32 value that specifies the ID value that uniquely identifies the process associated with the referenced connection to the server.

範例

C#

ServerConnection conn = new ServerConnection();
Console.WriteLine(conn.ProcessID);

PowerShell

$conn = new-object Microsoft.SqlServer.Management.Common.ServerConnection
Write-Host $conn.ProcessID

請參閱

參考

ServerConnection 類別

Microsoft.SqlServer.Management.Common 命名空間

其他資源

sp_who (Transact-SQL)

sys.sysprocesses (Transact-SQL)