EnumProcesses Method

后续版本的 Microsoft SQL Server 将删除该功能。请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。

The EnumProcesses method returns a QueryResults object that enumerates the Microsoft SQL Server processes running on a referenced instance of Microsoft SQL Server.

语法

object
.EnumProcesses( [ WhoByNameOrID ] )as QueryResults

Parts

  • object
    Expression that evaluates to an object in the Applies To list.

  • WhoByNameOrID
    String or small integer that identifies a login name or process ID.

Prototype (C/C++)

HRESULT EnumProcesses(
LPSQLDMOQUERYRESULTS* ppResults,
SQLDMO_LPCSTR szWho = NULL,
long lWho = -1);

Returns

A QueryResults object that contains one result set defined by these columns.

Column

Data type

Description

blocked

smallint

When nonnull, process ID blocking a request of the process ID listed by the row.

cmd

nchar(34)

Abbreviated indicator of current command. AWAITING COMMAND when no command is current.

cpu

integer

Cumulative CPU time for process.

dbname

nvarchar(129)

Database currently in use by process.

hostname

nchar(129)

If applicable, network name of the client workstation.

loginname

nvarchar(129)

Name of the SQL Server login.

memusage

integer

Number of pages in the procedure cache currently allocated to this process. A negative number indicates that the process is freeing memory allocated by another process.

program_name

nchar(129)

If applicable, name of the client application.

spid

smallint

SQL Server process ID.

status

nchar(31)

Execution state, such as running or sleeping.

ecid

smallint

Execution context ID used to uniquely identify the subthreads operating on behalf of a single process. If the computer is running an instance of SQL Server 7.0 or earlier, a value of zero is returned.

注释

If an application calls EnumProcesseson an instance of SQL Server version 7.0, the ecid column returns zero.

Applies To: