EnumLocks 方法
列舉 SQL Server 執行個體上持有的目前鎖定清單。
命名空間: Microsoft.SqlServer.Management.Smo
組件: Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)
語法
'宣告
Public Function EnumLocks As DataTable
'用途
Dim instance As Server
Dim returnValue As DataTable
returnValue = instance.EnumLocks()
public DataTable EnumLocks()
public:
DataTable^ EnumLocks()
member EnumLocks : unit -> DataTable
public function EnumLocks() : DataTable
傳回值
型別:System.Data. . :: . .DataTable
DataTable 系統物件值,包含 SQL Server 執行個體上指定之處理序所持有的目前鎖定清單。下表將描述傳回之 DataTable 的不同資料行。
備註
Use this method to determine the locks that are currently held on the instance of SQL Server. The information that is returned can help you identify locking problems that might affect performance.
範例
C#
Server srv = new Server("(local)");
DataTable d = srv.EnumLocks();
foreach (DataRow r in d.Rows)
{
Console.WriteLine("============================================");
foreach(DataColumn c in d.Columns)
{
Console.WriteLine(c.ColumnName + " = " + r[c].ToString());
}
}
PowerShell
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$d = $srv.EnumLocks()
foreach ($r in $d.Rows)
{
Write-Host "============================================"
Foreach ($c in $d.Columns)
{
Write-Host $c.ColumnName "=" $r[$c]
}
}