共用方式為


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: