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]
}
}