0

我遇到了一个问题,我试图在 SSIS 2008 变量中构建 XMLA 命令,以便我可以动态创建/处理 Analysis Services 2008 分区。我面临的问题是 XMLA 命令包含双引号,我尝试使用 \ 转义,但即使 SSIS 表达式框向我显示命令格式正确,ssis 字符串变量也会显示反斜杠。

例如我输入的 SSIS 表达式是:

"<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">"

然后正确评估 SSIS 表达式并显示为:

<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">

但在实际的 ssis 变量(作为表达式计算)中,值为:

<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">

请注意,反斜杠是可见的。

任何人都可以帮忙吗?

谢谢

4

2 回答 2

0

我们目前通过使用引号来转义引号成功地做到了这一点。这是我们工作脚本任务的一个示例:

 "   xmlns=""http://schemas.microsoft.com/analysisservices/2003/engine"">  " 
于 2014-09-09T13:33:11.590 回答
0
what worked in my case is :

1) wrap the XMLA in a select as below (taking  AdventureWorks for example and using variables as well):

"select
'<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">
    <ParentObject>
        <DatabaseID>AdventureWorksDW2012Multidimensional-EE</DatabaseID>
        <CubeID>Adventure Works</CubeID>
        <MeasureGroupID>Fact Internet Sales 1</MeasureGroupID>
    </ParentObject>
    <ObjectDefinition>
        <Partition xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\" xmlns:ddl200=\"http://schemas.microsoft.com/analysisservices/2010/engine/200\" xmlns:ddl200_200=\"http://schemas.microsoft.com/analysisservices/2010/engine/200/200\">
            <ID>Internet_Sales_"+@[User::year_recorded]+"</ID>
            <Name>Internet_Sales_"+@[User::year_recorded]+"</Name>
            <Source xsi:type=\"QueryBinding\">
                <DataSourceID>Adventure Works DW</DataSourceID>
                <QueryDefinition>SELECT [dbo].[FactInternetSales].[ProductKey],[dbo].[FactInternetSales].[OrderDateKey],[dbo].[FactInternetSales].[DueDateKey],[dbo].[FactInternetSales].[ShipDateKey], [dbo].[FactInternetSales].[CustomerKey], [dbo].[FactInternetSales].[PromotionKey],[dbo].[FactInternetSales].[CurrencyKey],[dbo].[FactInternetSales].[SalesTerritoryKey],[dbo].[FactInternetSales].[SalesOrderNumber],[dbo].[FactInternetSales].[SalesOrderLineNumber],[dbo].[FactInternetSales].[RevisionNumber],[dbo].[FactInternetSales].[OrderQuantity],[dbo].[FactInternetSales].[UnitPrice],[dbo].[FactInternetSales].[ExtendedAmount],[dbo].[FactInternetSales].[UnitPriceDiscountPct],[dbo].[FactInternetSales].[DiscountAmount],[dbo].[FactInternetSales].[ProductStandardCost],[dbo].[FactInternetSales].[TotalProductCost],[dbo].[FactInternetSales].[SalesAmount],[dbo].[FactInternetSales].[TaxAmt],[dbo].[FactInternetSales].[Freight],[dbo].[FactInternetSales].[CarrierTrackingNumber],[dbo].[FactInternetSales].[CustomerPONumber]
        FROM [dbo].[FactInternetSales]
                                WHERE "+@[User::WHERE_clause]+"</QueryDefinition>
            </Source>
            <StorageMode>Molap</StorageMode>
            <ProcessingMode>Regular</ProcessingMode>
            <ProactiveCaching>
                <SilenceInterval>-PT1S</SilenceInterval>
                <Latency>-PT1S</Latency>
                <SilenceOverrideInterval>-PT1S</SilenceOverrideInterval>
                <ForceRebuildInterval>-PT1S</ForceRebuildInterval>
                <AggregationStorage>MolapOnly</AggregationStorage>
                <Source xsi:type=\"ProactiveCachingInheritedBinding\">
                    <NotificationTechnique>Server</NotificationTechnique>
                </Source>
            </ProactiveCaching>
            <EstimatedRows>1013</EstimatedRows>
            <AggregationDesignID>Internet Sales 1</AggregationDesignID>
        </Partition>
    </ObjectDefinition>
</Create>

'

as xmla"

and assign the above as string to a String variable .

2) drag in an execute SQl task and supply variable in 1) as 'SourceVariable' . Run this SQL task on a connection manager  for normal transactional DB , say 'master' for instance .
3) save the 'Single Row' resultset from 2) in another String variable.
4)supply the variable from 3) to another Execute SQL task using the connection manager for SSAS cube .

hope this helps anyone landing on same ...
于 2018-03-24T17:03:33.193 回答