ServerConnection.TransactionDepth Property

Gets the current transaction depth for the referenced connection.

Namespace:  Microsoft.SqlServer.Management.Common
Assembly:  Microsoft.SqlServer.ConnectionInfo (in Microsoft.SqlServer.ConnectionInfo.dll)

public int TransactionDepth { get; }

Property Value

Type: Int32
An Int32 value that specifies the current transaction depth for the referenced connection.

A connection can experience nested transactions. The transaction depth refers to the number of nested transactions.

C#

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

PowerShell

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

Community Additions

Show: