I'm having an issue whereby I'm attempting to build up an XMLA command within an SSIS 2008 variable so that I can create/process Analysis Services 2008 partitions dynamically. The issue I'm facing is the XMLA command contains double quotes and I have tried escaping with \ but even though the SSIS expression box shows me the command correctly formatted, the ssis string variable shows the backslash.
e.g SSIS expression I enter is:
"<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">"
SSIS expression is then evaluated correctly and shown as:
<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
but in the actual ssis variable (evaluated as an expression) the value is:
<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">
Note the backslashes are visible.
Can anyone help?
Thanks
We are currently doing this successfully by using quotes to escape the quotes. Here is an example from our working script task:
" xmlns=""http://schemas.microsoft.com/analysisservices/2003/engine""> "
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 ...
Related
I am creating an SSIS package that will run each month. This particular stored procedure needs to run for one week at a time since the data returned is very large.
I have set up my stored procedure to with two parameters: #StartDT and #EndDT. I created two SSIS variables: StartDT and Wk1EndDT (I'll create the other start and end dates for the weeks once I get this one working).
StartDT has this expression:
(DT_DATE)((DT_WSTR, 4)YEAR(DATEADD("mm", -1, GETDATE())) + "-" +RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD("mm", -1, GETDATE())),2)+"-01")
Wk1EndDT has this expression:
DATEADD("DD",7, #[User::StartDT])
I'm using a DataFlow task with a SQL command text of:
EXECUTE dbo.uspUploadWk1 ?,?
When I go to preview the results, I receive the following error message:
There was an error displaying the preview.
No value given for one or more required parameters. (Microsoft SQL Server Native Client 11.0)
I have the parameters set like this:
I am not sure why this isn't working. I've searched all over and have not found an answer. I am using Visual Studio 2015.
Assuming an OLE DB Connection Manager, the Mappings tab should be using a zero based ordinal system on the Parameters column. Yes, it defaults to naming them as Parameter0, Parameter1, etc but for an OLE DB connection manager, you'll use the ordinal position of the question marks, ?, starting at zero.
For ODBC, it becomes a 1 based counting but still uses ? as the parameter place holder.
ADO.NET uses named parameters so we'd match EXECUTE dbo.uspUploadWk1 #Parameter0, #Parameter1 but the ADO.NET source component doesn't support parameterization
Reference on parameters and mapping for Execute SQL Task but the syntax remains the same for Data Flow Task components
I need to get last processed date of SSAS cube in SSIS and save it into a variable.
I've tried a "Execute SQL task":
SELECT LAST_DATA_UPDATE as LAST_DT FROM $system.mdschema_cubes
WHERE CUBE_NAME = 'CubeName'
It works ok in MSSQL management studio MDX query window but in SSIS it says: Unsupported data type on result set binding.
Then I've tried:
WITH MEMBER [Measures].[LastProcessed] AS ASSP.GetCubeLastProcessedDate() SELECT [Measures].[LastProcessed] ON 0 FROM [CubeName]
And it says '[ASSP].[GetCubeLastProcessedDate]' function does not exist.
Any ideas how to do this?
Thank you
A linked server might be your best option;
Create the linked server with the following, changing as appropriate:
EXEC master.dbo.sp_addlinkedserver
#server = N'LINKED_SERVER_OLAP_TEST', --Change to a suitable name
#srvproduct='', --Creates the productname as blank
#provider=N'MSOLAP', --Analysis Services
#datasrc=N'localhost', --Change to your datasource
#catalog=N'TESTCUBE' --Change to set the default cube
Change the data source of your Execute SQL Task to make sure it is pointing to any of the databases where the linked server is hosted, I.E. don't use an analysis service datasource use a standard OLE DB. Then have the following in your execute SQL task (Changing as appropriate).
SELECT *
FROM OpenQuery(LINKED_SERVER_OLAP_TEST,'SELECT LAST_DATA_UPDATE as LAST_DT FROM $system.mdschema_cubes
WHERE CUBE_NAME = ''CUBENAME''')
Set the variable to be DATETIME and the result set to be single row.
There may well be other ways to do this, however I have always found this method the most straight forward.
I am pretty new to SSIS (my first real project) and I have built a package that successfully performs some insert operations on a database. I want to deploy it to multiple environments, so I have created a connection manager whose connection string will be passed in from the command line which will in turn be defined in a command file.
The command that I run from the command line is ...
DTExec /F InitialDatabseImport.dtsx /CommandFile InitialCommandFile.config.txt
In the command file (InitialCommandFile.config.txt) I have the following variable assignment ...
/SET \Package.Variables[User::DBConnectionString].Properties[Value];"\"Data Source=(localdb)\ProjectsV12;Initial Catalog=DatabaseName;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;"\"
Running this I get the following error ...
Option "Source=(localdb)\ProjectsV12;Initial" is not valid.
It seems that is delimiting the connection string on spaces rather than semicolons.
I have tried a number of configurations with quotes. Here I changed the quotes in front of "Data" to something that seemed to make more sense ...
/SET \Package.Variables[User::DBConnectionString].Properties[Value];\""Data Source=(localdb)\ProjectsV12;Initial Catalog=MarketingPrefsDB;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;"\"
which returned the error ...
The argument "\Package.Variables[User::DBConnectionString].Properties[Value];\"Data" has mismatched quotes.
And this one, I wrapped the entire assignment in quotes ...
/SET "\Package.Variables[User::DBConnectionString].Properties[Value];\"Data Source=(localdb)\ProjectsV12;Initial Catalog=MarketingPrefsDB;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;\"";
which returned the error ...
Argument ""\Package.Variables[User::DBConnectionString].Properties[Value];\"Data" for option "set" is not valid.
Has anyone else who has seen this problem been able to figure it out?
Thanks,
G
UPDATE - 2014/07/21
When I put the SET command directly in the command line I am getting a slightly different error ...
Command Line ...
C:\Project>DTExec /F QuaeroInitialImport.dtsx /SET \Package.Variables[User::DBConn
ectionString].Properties[Value];"Data Source=servername;Initial Catalog=DatabaseName;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;"
Error Message
Argument ""\Package.Variables[User::DBConnectionString].Properties[Value];\"Data Source=servername;Initial Catalog=DatabaseName;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;" for option "set" is not valid.
I've met similar issue and just share my work-around in case others reach here thru google.
My case is:
Deploying the package on SQL Server 2014, and I use some package parameter in the package and met this issue. I've met this if I don't use package parameter on another server running SQL Server 2014 also (both server are running the same version of SQL Server 2014).
I fix this by replacing all spaces in the keywords of the connection space with an underscore (_). The connection work for me on my server like:
Data_Source=xxx.xxx.xxx.xxx,xxxx;Initial_Catalog=ABC_DEF;Provider=SQLNCLI11.1;Persist_Security Info=True;Auto_Translate=False;User_ID=userabc;
Please note even I have forgotten to replace some space in some keyword, it still works.
So I finally change it as below:
Data_Source=xxx.xxx.xxx.xxx,xxxx;Initial_Catalog=ABC_DEF;Provider=SQLNCLI11.1;Persist_Security_Info=True;Auto_Translate=False;User_ID=userabc;
So... it doesn't make me comfortable in this case as I am not sure actually if it is working on a correcting settings... you still have to verify it yourself.
I am creating a SSIS package that involves a where clause as:
WHERE effectiveDate >= #effectiveDate
Therefore, I defined #effectiveDate at the package level so that I can pass in value from a sql command using a different connection.
At the OLE DB source, I selected 'SQL command', and put the code as
Select ... FROM ...
WHERE effectiveDate >= ?
When I click on the 'parameters', an error appears:
'Parameters cannot be extracted from the SQL command. blablabla... use "SQL command from variable"...'
I am trying to avoid using SQL command from variable and try to locate the problem since I should be able to pass in variable.
Can anyone help? Thanks a lot!!
When building an OleDbCommand, you should actually name the parameter as the package is expecting, such as
OleDbCommand cmd = new OleDbCommand( "select ... from... where... eff > #yourPkgPameterName");
cmd.Parameters.AddWithValue( "#yourPkgPameterName", whateverValueToSend );
It's been a while for SQL-based parameters and don't remember if the AddWithValue() method is expecting the "#" or not... may need to try without it if it fails.
I have a problem with a sql query. Through the query I am trying to search database for any occurrences of string (can be anything) in a column using the SQL LIKE command. The problem is that it works fine for most of the strings say john, jim, ji"m , but does not work when i include the following characters which are ( ' , { , } , and a single quotation mark). MYSQL query takes care of these special cases by putting them in [] block whenever user enters them .
But i am getting the following error when i go to query the database using the GetSelectCommand() in VB.NET
Exception Details:
System.ApplicationException: Number of
values provided must be equal to the
number of placeholders in query.
I have checked the query over and over again .. but its fine .
My database server is Sql Server 2008.
So my application throws the exception in this command:
Using reader As MustDisposeDataReader = _
pmSystem.DatabaseManager.GetSelectCommand(selectStatementBuilder.ToString(), New Object() {})
Where MustDisposeDataReader is an instance of a class in an internally developed library, which inherits from System.Object. pmSystem is an instance of the class PlanManagerSystem which implements the commandlayer. GetSelectCommand() takes the select command
Your single quotes are probably formatted incorrectly. Since it says the number of values are wrong it looks like your single quotes are off.