Accessing Query Context in Stored Procedures

Applies to: SQL Server Analysis Services Azure Analysis Services Fabric/Power BI Premium

The execution context of a stored procedure is available within the code of the stored procedure as the Context object of the ADOMD.NET server object model. This is a read-only context and cannot be modified by the stored procedure. The following properties are available on this object.

Property Type Description
CurrentCube Cube The cube for the current query context.
CurrentDatabaseName String The identifier of the current database.
CurrentConnection Connection A reference to the connection object in the current context.
Pass Integer The pass number for the current context.

The Context object exists when the Multidimensional Expressions (MDX) object model is used in a stored procedure. It is not available when the MDX object model is used on a client. The Context object is not explicitly passed to or returned by the stored procedure. It is available during the execution of the stored procedure.

See Also

Multidimensional Model Assemblies Management
Defining Stored Procedures