共用方式為


EnumDependencies Method

未來的 Microsoft SQL Server 發行版本將不再提供此功能。請避免在新的開發工作中使用此功能,並計劃修改目前使用此功能的應用程式。

The EnumDependencies method returns a QueryResults object that enumerates Microsoft SQL Server database user objects and user object dependency relationships.

語法

object
.EnumDependencies( [ DependencyType ] )as QueryResults

Parts

  • object
    Expression that evaluates to an object in the Applies To list.
  • DependencyType
    Long integer that directs output as described in Settings.

Prototype (C/C++)

HRESULT EnumDependencies(
LPSQLDMOQUERYRESULTS* ppResults,
SQLDMO_DEPENDENCY_TYPE DependencyType = SQLDMODep_Parents);

Settings

Specify the value of the DependencyType argument using these SQLDMO_DEPENDENCY_TYPE values.

Constant Value Description

SQLDMODep_Children

262144

Lists all components that depend on the referenced SQL Server component.

SQLDMODep_DRIOnly

2097152

Lists components that depend on the referenced SQL Server component in a DRI relationship.

SQLDMODep_FirstLevelOnly

1048576

Lists only immediate parents. Combine with SQLDMODep_Children to list only immediate children.

SQLDMODep_FullHierarchy

65536

Alters the default result set describing hierarchy relationship in a result set row.

SQLDMODep_OrderDescending

131072

Applies descending order to returned list.

SQLDMODep_Parents

0

Lists all objects on which the referenced SQL Server component depends.

SQLDMODep_/ReturnInputObject

524288

Includes SQL Server component referenced by the SQL Distributed Management Objects (SQL-DMO) object in the list returned.

SQLDMODep_Valid

4128768

All dependency constants combined using an OR logical operator.

Returns

A QueryResults object that contains up to three result sets. When no user-defined data types, defaults, or rules are contained in the dependency tree, a single result set is returned, defined by these columns.

Column Data type Description

oObjName

nvarchar(129)

Database object name.

oOwner

nvarchar(129)

Database object owner name.

oSequence

smallint

Indicator of distance in the hierarchy between the specified object and the object listed.

oType

integer

Database object type, enumerated by SQLDMO_OBJECT_TYPE.

RelName

nvarchar(129)

Displayed when SQLDMODep_FullHierarchy is specified. Hierarchically-related database object name.

RelOwner

nvarchar(129)

Displayed when SQLDMODep_FullHierarchy is specified. Hierarchically-related database object owner name.

RelType

integer

Displayed when SQLDMODep_FullHierarchy is specified. When the RelName value is nonNULL, RelType is the hierarchically related database object type, enumerated by SQLDMO_OBJECT_TYPE. When RelName value is NULL, the value 0 is returned and can be ignored.

When the dependency tree contains defaults, rules, or user-defined data types, one or two additional result sets are returned by the EnumDependencies method. When rules or defaults are contained, a result set is returned, defined by these columns.

Column Data type Description

oOwner

nvarchar(129)

Database object owner name.

oRuleDefName

nvarchar(129)

Database object name.

oSequence

smallint

Indicator of distance in the hierarchy between the specified object and the object listed.

oType

integer

Database object type, enumerated by SQLDMO_OBJECT_TYPE. Value is SQLDMOObj_Default or SQLDMOObj_Rule for all rows.

When user-defined data types are contained in the dependency tree, a result set that enumerates the data types is returned. The user-defined data type result set is defined by these columns.

Column Data type Description

oType

integer

Database object type, enumerated by SQLDMO_OBJECT_TYPE. Value is SQLDMOObj_UserDefinedDatatype for all rows.

oUDDTName

nvarchar(129)

User-defined data type name.

oOwner

nvarchar(129)

User-defined data type owner name.

oSequence

smallint

Indicator of distance in the hierarchy between the specified object and the object listed.

Applies To:

Database Object

Table Object

DBObject Object

Trigger Object

ReplicationStoredProcedure Object

View Object

StoredProcedure Object

UserDefinedFunction Object