Database.GetTransactionCount メソッド

データベース上の開いているトランザクションの数を取得します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
Public Function GetTransactionCount As Integer
'使用
Dim instance As Database 
Dim returnValue As Integer 

returnValue = instance.GetTransactionCount()
public int GetTransactionCount()
public:
int GetTransactionCount()
member GetTransactionCount : unit -> int
public function GetTransactionCount() : int

戻り値

型: System.Int32
データベース上の開いているトランザクションの数を示す Int32 値。

説明

データベースのスナップショット分離設定を True に変更するとき、このメソッドが役立ちます。開かれたトランザクションが長時間実行されていると、呼び出しに時間がかかる場合があるためです。

使用例

VB

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server

'Reference the AdventureWorks2012 database.
Dim db As Database
db = srv.Databases("AdventureWorks2012")

'Display the number of open transaction on the database.
Console.WriteLine(db.GetTransactionCount.ToString)

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2012")

Write-Host $db.GetTransactionCount()

関連項目

参照

Database クラス

GetTransactionCount オーバーロード

Microsoft.SqlServer.Management.Smo 名前空間

その他の技術情報

データベース オブジェクトでの作業

sys.dm_tran_active_transactions (Transact-SQL)

データベースの作成、変更、および削除

CREATE DATABASE (Transact-SQL)