Statement (Command Interface)

ms134806.note(zh-cn,SQL.90).gif注意:
  下一版本的 Microsoft SQL Server 将删除该功能。请不要在新的开发工作中使用该功能,并尽快修改当前还在使用该功能的应用程序。

The Statement property of the Command interface contains the text of the command statement.

Applies To:clsCubeCommand, clsDatabaseCommand, clsRoleCommand

Data Type

String

Access

Read/write

备注

For more information about types of command statements, see CommandType.

The names used in statements that define actions, calculated members, named sets, and calculated cells must be unique within a cube. For example, if you create an action named Test, you cannot create a calculated cells definition named Test. For more information about naming conventions for Decision Support Objects, see Considerations For Naming Decision Support Objects.

Examples

A. Creating a Command Object (cmdCreateAction)

Use the following code to create a cmdCreateAction command object:

CommandObject.Statement = "CREATE ACTION Sales.ShowCustDetails " & _
    "FOR [Customer] MEMBERS As " & _
    "'IIf(Customers.CurrentMember.Properties(""Existing Customer"")" & _
    " = ""True""," & _
    """http://MyServer/CustomerDetails.ASP?CustID="" + " & _
    "Customers.CurrentMember.ID,'') " & _
    "TYPE = URL " & _
    "APPLICATION = 'IE' " & _
    "DESCRIPTION = 'Launch the customer details page for " & _
    "this specific customer.'"

You can use CURRENTCUBE in command statements to refer to the cube that contains the command object. This syntax makes it easier to copy command objects between cubes. For example, you can reconstruct the previous statement as:

CommandObject.Statement = "CREATE ACTION CURRENTCUBE.ShowCustDetails " & _
    "FOR [Customer] MEMBERS As " & _
    "'IIf(Customers.CurrentMember.Properties(""Existing Customer"")" & _
    " = ""True""," & _
    """http://MyServer/CustomerDetails.ASP?CustID="" + " & _
    "Customers.CurrentMember.ID,'') " & _
    "TYPE = URL " & _
    "APPLICATION = 'IE' " & _
    "DESCRIPTION = 'Open the customer details page for " & _
    "this specific customer.'"

B. Creating a Command Object (cmdCreateMember)

Use the following code to create a cmdCreateMember command object:

CommandObject.Statement = "CREATE MEMBER Sales.Measures.PROFIT AS " & _
    "'Measures.Sales - Measures.Cost'"

C. Creating a Command Object (cmdCreateSet)

Use the following code to create a cmdCreateSet command object:

CommandObject.Statement = "CREATE SET CURRENTCUBE.[ImportedBeer] AS " & _
    "'Filter(Product.Members, " & _
    "(InStr(1, Product.CurrentMember.Name, ""Imported Beer"")))'"

D. Creating a Command Object (cmdUseLibrary)

Use the following code to create a cmdUseLibrary command object:

CommandObject.Statement = "USE LIBRARY ""MyStatFunctions.dll"""

E. Creating a Command Object (cmdCreateCellCalculation)

Use the following code to create a cmdCreateCellCalculation command object:

CommandObject.Statement = CREATE SESSION CELL CALCULATION " & _
    "[Sales].[Mexico Adjustments] FOR " & _
    "'(Descendants([Mexico], [City], SELF))' & _
    "AS '<expression>'," & _
    "CONDITION = '[Time].CURRENTMEMBER.NAME=[2000]'"

F. Returning a Command Object Statement

Use the following code to return a command object statement:

Dim strCommandStatement As String
strCommandStatement = CommandObject.Statement

请参阅

参考

Command Interface

其他资源

CREATE MEMBER 语句 (MDX)
CREATE SET 语句 (MDX)

帮助和信息

获取 SQL Server 2005 帮助