SSRS Code and Automated Reports - sql-server-2008

I am currently trying to automate reports using SSRS in SQL Server 2008, requiring little to no user input at all.
I have the queries already to acquire the data, but they require datetime parameters which are retrieved from an invoices table in the database.
Is there any way to automate this, without requiring user input? I'd like to have these reports fire off every Monday morning without prompting. We also have an internal web site which is used for administrative work, written in ASP and C#, that I can use in conjunction in need be.
Regards and thanks

You should be able to do this. In each report you can set a query to retrieve parameter values and you can also specify a query for the default values.
So
Add a parameter and have that parameter be passed to your stored proc that gets your data
Set the available and default values for that parameter to a sql query that returns the value you need for the parameter.
You'll need to do this for each parameter. Then as long as all parameters in the report have default values the report will run without prompting for parameters.

Related

Taking snapshots of reports

I've created a snapshot of my report in order to improve the performance. However, it appears that it's only using the snapshot on the default values for the report. If I change the values, it appears that it's calling the procedure again (?) or rendering the report again.
The report has a dataset which calls a procedure (no input parameters), which can be filtered using the input parameters.
The snapshot has been created using the Snapshot Options and Processing Options. Any ideas what I need to do in order for the report to use the snapshot all the time?
That is basically how snapshots work - they are a point-in-time copy of the report results taken with the default parameter values. If you change the parameters on the report then SSRS will not use the snapshot because the report results could be different.
It sounds like your report is always returning all data from the procedure, which is then filtered at report rendering time based on the parameter values. This is not a good design and is probably the reason for your report performance problems. Try modifying the procedure to accept parameters and passing these from the report - this way the procedure only returns as much data as is necessary to display in the report and the report server does not have to do filtering when rendering the report.

SSRS: Caching a shared Oracle Dataset with date parameter

I am using SSRS (2008R2) to create a large report against an Oracle
database.
Because of the size of the report I wanted to cache the shared
dataset overnight.
The dataset has a single parameter which should default to today's
date but be changeable in the report (although this would trigger
another cache).
I have struggled with this for 3 days and wanted to document how I got it to work, as well as get feedback on my approach.
1. Oracle Datasource:
I found that passing parameters to the dataset only worked well for me using the native Oracle drivers, not the OLE DB drivers.
2. Shared Dataset:
I was never able to get SSRS to pass a date parameter to Oracle. In my Oracle query I therefore used the conversion TO_DATE(:EffectiveDate,'YYYY-MM-DD"T"HH24:MI:SS') (you'll see why I had to use ISO 8601 format later).
When adding the variable :EffectiveDate to my SQL query a parameter was automatically added to by shared dataset. This initially caused the Oracle error ORA-01008: not all variables bound. This was resolved by deleting the dataset parameter and then clicking "refresh fields" on the dataset query screen to re-create it. The only difference apparently being that now the parameter name has a colon.
I have set the dataset parameter up as shown below in the screenshot:
The parameter is of type "text" and defaults to today at midnight in ISO 8601 format (=Format(Today(),"yyyy-MM-dd\T\0\0:\0\0:\0\0"))
3. Report Dataset:
The Report Dataset uses the Shared Dataset above and also has a dataset parameter. In this case I want the report dataset parameter to take a date from a report parameter but pass a string to the shared dataset parameter as below:
The Dataset Parameter is set to the value =Format(Parameters!EffectiveDate.Value,"yyyy-MM-dd\T\0\0:\0\0:\0\0")
4. Report Parameter:
The Report Parameter is set to "date" type as below with a default of =Today():
5. Shared Dataset Caching:
First I set the Shared Dataset to use cached data (on the report server via your browser):
Then I set up a "Cache Refresh Plan":
The Cache Refresh Plan seems very picky about Parameter format and it was this last step that only seems to work if passing dates as ISO 8601 compliant strings.
6. Notes:
:EffectiveDate is the name of my Oracle string bind variable and EffectiveDate is the name of my Report parameter. Change your code appropriately.
I was only interested in the date (i.e. not the time). If you need time as well you may need to make some changes.
In order to let the end user know how old the data was, I added an extra column ,SYSDATE AS DATA_AGE to my SQL Query. I was then able to reference the age of the data in my report header with First(Fields!Report_Date.Value, "<report_dataset_name")
I am able to create snapshots of the report but all of the prompts are greyed out, even though all the other prompts only effect report filtering.
To have different prompt defaults in my snapshots I used the test IsNothing(User!UserID). I'd love to know if there was a better way.
My example isn't necessarily in the order in which I set things up (i.e. I reference the Report Parameter before showing its setup).

SSRS call stored procedure using ReportItems! textbox. Maybe custom report code?

I need to call a stored procedure during my report to insert values into a table. These values are the result of fields from the dataset added. For example, I have a row of values, and the far right column is "ReportItems!TextBox1.Value + ReportItems!TextBox2.Value ..." This gives the correct total on the report. Now I need to call a procedure using this value as a parameter.
Using a stored procedure as a dataset, I am unable to reference the ReportItems! I am also unable to create additional report parameters (even internal or hidden) which could be a result of a dataset due to the reporting infrastructure we are using.
I know using custom report code, I can call a stored procedure and also reference the ReportItems, but I have been unable to find the correct syntax. I am not familiar with VB.net so please be specific. If i could get an example of how to call: Procedure TEST_INSERT(ReportItems!TextBox1.Value), I would be able to figure out how to implement it.
I am using an oracle backend as my data source.
Thanks
If I've understood you correctly, you want to do an database update using a value calculated with an expression in your report. My answer to this would be threefold.
First up: don't do it!.
Second: seriously, don't do it!! Reporting services is not meant or well suited for this kind of task, you most likely are looking at an XY-Problem.
Third, if you insist on doing it anyways, the easiest way I can think of to accomplish that is by using a seperate report to trigger the update, and pass the value you're after into a parameter for that report. In the main report, you set a click action on the cell with the total that calls the report, with the same value into the parameter.
A similar setup which may work as well, is to create a parameter based on the first dataset with that same "sum" expression you mention, and pass that down to another dataset.
However: don't do it! ;-)
I would set up a dataset in the report service that calls an update or insert function in oracle and returns a value/s. This way you can send in the total you need calculate and produce a result telling the user if the update was successful.
There is no special method for doing this just select or enter your procedure name and refresh the fields to update the parameter/s. See Oracle stored procedure in SSRS.
Also using this method you can run the stored procedure in oracle, update the table and display the results.

It's possible to save report parameter wrote by user?

I have report where I ask user to write path to dir of files. This parameter have default value on start, but I want to allow user change it. From moment where he change it parameter wrote by user will be displayed as default on next render time.
Edit:
I use Buissnes Inteligence and SQL SERVER 2008r2
I don't think this can be done in SSRS alone.
What you could do would be to write a procedure to produce your report output, which accepts the directory path as a parameter and saves it to a user lookup table, before producing the report data.
You could then use a query on the user table to produce the default value for the parameter in SSRS.

Default Values on a Shared Data Set in SQL Reports 2008

I would like to know if it is possible to set the default values of a shared dataset with the results of another dataset.
I am currently creating datasets to allow a user group to run ad hoc sql reporting on a SharePoint intgrated deployment.
I know how to do this in an actual report but I would like to do it in the shared dataset so that users would not then have to configure the parameters in the report when they are creating ad hoc reports.
I can see how do create default parameters if I type in the values, however the values may change over time so I want to autmotaically pick up any changes from the database by running a query to get the appropriate values.
Has anyone achieved anything similar before or could suggest an alternative way to achieve this?
PS quite new to SQL reports. Thanks in advance