SSIS multiline string variables , in VS 2008 - ssis

I need to store a large query into a string variable.
When I paste the sql query into the Value property of the variable, I see only one line.
I am using VS 2008 , BIDS to design the package.
I think this is a bug as stated here,
what I am actualy intersted is a workaround to bypass this.

We use a parameters table in a SQL database, then load long strings into variables using a simple SQL query. This has the additional advantage that you can refactor the query code without opening SSIS.
It also allows multiple packages to easily share common query code.
Edit: Of course, if you only want to do this once...
Manually edit the XML. Put a placeholder value in the variable, then open the .dtsx in a text editor, locate the placeholder value, and replace it with the value you need.
Please back up your package prior to doing this.

Another work around - you can set the EvaluateAsExpression to True and put the SQL query in the Expression. The Expression will have a ... button which you can click to edit a multi-line value.

Related

SSIS: Read property from another component?

I created a simple SSIS job that exports a sql table to a text file. Since the filename's dynamic, I set the ConnectionString in the Flat File Connection Manager to an expression. So that works fine and the text file's generated based on the expression.
Now, I need to email that file. Is it possible to access the ConnectionString property from another component?
I understand that I can use variables, but I don't want to write code for this.
Thanks.
If you want to use an expression in multiple components you have to store it in a variable.
Create an SSIS variable, change the variable Evaluate As Expression property to True and write the expression in the variable Expression property.
Then in each component just use this variable as Expression
Or just write the same expression in each component

MS Access - "Cannot Find the Name... In the Expression" error - IIf CDbl statement

My Problem
I have a fairly straight forward autoexec macro to perform a version control check for my split database. I have a table in the frontend called LocalVersionNumber, and a table in the backend called LiveVersionNumber. Each version number may have multiple values (ex. which version of the backend is being used, which frontend, etc). Because of this, the value in these tables are parsed via the queries __LiveVersionParser_Q and __LocalVersionParser_Q. Without going into too much wasted detail, the local version number should always be equal or greater than the live version number.
I wrote up a query that compared my local & live parsed values - and via IIF expressions, determined the logic to update or keep with current version. This test query ran without issue, but now that I've pulled the logic into a autoexec macro and I'm getting the error:
Cannot find the name '__LiveVersionParser_Q' you entered in the
expression.
I've double checked, and the table and fields are spelled correctly. I've even gone as far as to copy and paste the statement from the macro back into a query, and the query executes properly still.
The Code
(In Macro Builder not VBA - ugh)
"IF" Action
CDbl([__LiveVersionParser_Q].[DevelopmentVersion])
<=CDbl([__LocalVersionParser_Q].[DevelopmentVersion])
Then... execute my update frontend logic.
NOTE: For those asking "why use CDbl?", this is used because the version number is a text string with multiple values separated by ".". After parsing the versions, these strings are then compared by converting them to a double (using CDbl) to see which is greater.
Troubleshooting
As I stated earlier, this statement DOES work, just not in this macro. I've troubleshot it by using the following query (to keep it consistent, here is the 'design' view expression I tested rather than SQL):
Expr1: IIf(CDbl([__LiveVersionParser_Q].[DevelopmentVersion])
<=CDbl([__LocalVersionParser_Q].[DevelopmentVersion]),"OK","UPDATE")
Any suggestions? I feel like I'm missing something simple.
I have found a workaround (not a root cause & solution). If someone can provide a proper explanation of the root cause, I will gladly switch over answer credit to them!
But in the meantime, should anyone else run into a similar problem, here is my workaround:
Step 1:
As stated in my question, I have a query that runs the "IF" action perfectly fine. So I used that to output a Result field that states either "OK" or "Update".
Step 2:
I changed my autoexec macro to be as follows:
IF...
DMax("Result","__VersionControl_FinalTest")="Update"
THEN...
Run my update code.
ELSE...
CancelEvent
END IF
NOTE: I tried to use a simple statement of:
IF...
[__VersionControl].[Result] = "Update"
However, when I ran that macro, I again received the error 2482 ("cannot find the name...").
Why DMax is able to 'find' the __VersionControl_FinalTest query and the IF statement cannot, I do not know - but at least I'm back up and running.

SSIS 2008: Conditional logic to use different sources in Data Flow Task

I have an SSIS 2008 package with data flow task using Task Factory Salesforce.com source, and in the WHERE clause is the below statement, which works fine.
WHERE SystemModstamp > <#User::dt_last_success>
I'd like to pull off a conditional 'IF #load_all_data=True THEN do not include the above WHERE clause, and if False then include it. I've been told that this is not possible in Salesforce Object Query Language (SOQL) to include that logic in the WHERE clause of the above query* , which means that I'll need two separate data sources: one with the current WHERE.., and one without.
I'd prefer not to copy-paste each data flow task, and the only different being the WHERE clause, to pull this off.
Question: What's the easiest way to pull off two sources based on logic with a parameter in a data flow task, using the same destination? Preferably without a JOIN that requires sorting.
Thanks in advance.
Jim
https://salesforce.stackexchange.com/questions/57277/ssis-package-connecting-to-salesforce-with-or-parameter-y
I'm not familiar with the TaskFactory's Salesforce.com source, but most SSIS things allow for the concept of Expressions to be applied to them. Looking at the documentation for SFDC and knowing the PW folks, surely they allow for this.
Create a Variable, LoadAllData of type boolean and set it to False
Create a second variable, of type string, called Query. You will then need to set the EvaluateAsExpression property to True and then use an expression like the following (note the double quotes are part of the Expression.
"SELECT MyCols FROM MyTable "
+ (#[User::LoadAllData]) ? "" : "WHERE SystemModstamp > <#User::dt_last_success>"
That will build the query of SELECT MyCols FROM MyTable for the full load, SELECT MyCols FROM MyTable WHERE SystemModstamp > <#User::dt_last_success> for the incremental load.
Once you verify the strings are working, as expected with the variable toggle, you then go into your data flow, right click on the SFDC source and under Expressions, there ought to be something that corresponds to the SalesForceQuery and you then assign as its value #[User::Query]
Tying this all together, you'd then use the /SET property when you run the package to flip the value of LoadAllData to True whenever you need the full load (which I assume is the exception and not the standard case).
dtexec /file ./SFDC.dtsx /Set \Package.Variables[User::LoadAllData].Properties[Value];1
^^^ That's approximate. I haven't tried to set a boolean from the command line so it might expect True, true or possibly TRUE. Quick experimentation on your part should reveal the specific syntax.

Is there a solution for localizing "parameters/prompt" in SSRS 2008 R2 or 2012?

I'm using now SQL Server 2008 R2.
My website shows the report exactly as it is, including the container where the parameters appear (the client prefers it that way).
However, my website solution includes localization (Portuguese, English, Spanish).
I've tried to translate the parameters by creating one parameter for each language, and then show them according the selected one. It didn't work in SSRS 2008. Because I don't know how to find the visibility properties of prompt.
Does anyone know a solution... Or if SQL Server 2012 has solutions for translating parameter's prompt, or conditional visibility?
Thanks.
The only solution I've found so far (SSRS 2008, 2008R2, 2010, 2012) is to break the DRY commandments, and duplicate the reports with language codes as part of the report name (e.g. MyReport_sp.rdl, MyReport_de.rdl, etc) and then place a web service between the client request and the SSRS instance. The web service then has to field the request to the correct report based on a "Culture" parameter passed with the client's request.
This is NOT a good solution, though at least the Culture param is used in localizing the rest of the report as well. We still have hopes that at some future date MS will add prompt localizability and we can rename the report to MyReport.rdl and just have everything actually localized. Hmm, what a concept...
Another workaround would be to just put a number in the prompt for the parameter then prefix the label of each parameter with the localised version by either using "get values from query" or by using the expression builder with a switch statement in the label expression.
For the get values from query option you would have a dataset something like this if you have the translated versions in the query:
SELECT ParamLabel, ParamValue
FROM MyLocalisedParameters
WHERE UserLanguage = #Language
Or like this if not:
SELECT
CASE #Language
WHEN 'pt-PT' THEN 'Selecione Departamento: ' + ParamLabel
WHEN 'es-ES' THEN 'Seleccionar Departamento: ' + ParamLabel
ELSE 'Select Department: ' + ParamLabel
END AS ParamLabel
, ParamValue
FROM MyParametersTable
in both cases creating and assigning the Globals!Language to a Parameter called #Language.
Or if using the expression builder for a hardcoded set of values it would look something like this:
either way the end result would look something like this:
Not perfect but functioning and easier to maintain than several copies of the same report.
If you want it to look a bit tidier then just have the Parameter prompt as only one entry in the parameters list and set it to the default value to avoid repetition on every line.
There is none...
As per connect.microsoft.com, this feature has been requested after SSRS 2005 has been released, and while it is on Microsoft's TODO list, the programmer time to do this has never been allocated, and hence in 2012, SSRS is still not capable of doing that.
Although it's (with much effort) possible to translate everything else, it's not possible to translate the parameter prompt.
There is NO conditional visibility either, visibility of parameters is fixed.
Also, there is no way having SSRS use a supplied language instead of the one set in the browser language settings.
The only thing that you CAN do is write a C# program that loads your XML file, get's the report's parameter name(s) (and possibly the report's name as well), looks them up in a database, and automagically creates N reports for n languages.
Then, you have to redirect your users to the report in their language.
You then only need to write an upload tool, because you won't want to do that by hand.
The other way is to use the ReportViewer control, and re-implement parameter selection.
I think there's CrissCross that tries to do that, but it failed in all but 2 of the reports that I tested.
An evil hack would be:
parametername: babla_language1 / blabla_language2 / blabla_language3 / blabla_language4
and then use jQuery to get that string. do string.split('/')[index_of_language]
and then prey that / is never within "blabla_languageXY"
Edit:
I actually did that. You have to use setInterval to do it, because there is no way to detect change when you select a parameter.

Reporting Services - translating labels into different languages

I'm finishing up my reports in my SQL Server 2008 Reporting Services project, and as one of the last steps, I need to make things translateable.
Since I have a bunch of reports, and they all share some identical labels, I decided to put all those labels I need to show into a SQL Server table, and I am surfacing that contents as a DataSet dsReportLabels in my reports.
This DataSet basically contains two fields: LabelName is the name of the label (e.g. "Count of items"), and Caption contains the text in the chosen language to be shown on the report.
But now here comes my mental block: how do I assign the dsReportLabels.Caption value to a e.g. textbox, based on the dsReportLabels.LabelName ?
So I need something like (pseudo-LINQ statement):
Textbox1.Value = from dsReportLabels
where LabelName = "some value"
select Caption;
but how do I express that in a Reporting Services code snippet?
I know how to reference things like Parameters!MyParameterName.Value and so on - but that doesn't really work here when I'm trying to extract a value from one column of the DataSet, given the value of the other column in that DataSet.
I bet this is totally easy to do in the end.... just can't seem to wrap my head around this right now.... anyone out there know how to do this?
This MSDN blog post describes one way of doing it. Essentially:
Create a lookup table with the LabelID, Language, and Caption.
Create a Stored Proc that gets all of the labelIDs and captions for a specified language.
Store the results of the SP in a dataset.
Store the dataset in a multi-value parameter.
Use the multi-value parameter in a custom lookup function.
So, the expression in your label textbox would call the custom function with the labelID, which would get the appropriate caption for the appropriate language.
Report Server 2008 also has a built-in Lookup function that may allow you to skip steps 4 and 5. If this is the case, your expression would call the built-in lookup function, which would go directly to the dataset. I don't have RS 2008, so I can't test this.