what runs the subscribed report in SSRS? - reporting-services

so my question is, what runs the subscribed report in SSRS ? I mean when I subscribe to report and give it a desired time when it should run and send me the file. something does this right ? so I want to know what runs it ? is it a procedure in SQL function ? well the reason why I want to know this is that I want to run SQL update before each time this scheduled report starts.
I can just create procedure that will do the update I want before the scheduled time but, still it will be more practical to integrate it within the job itself

Short answer, these subscriptions are run as database jobs through the SQL Server Agent.
They are created with GUID type names:
The one job step will have a command like:
exec [ReportServer].dbo.AddEvent #EventType='SharedSchedule', #EventData='8df4ff30-97d3-41f7-b3ef-9ce48bfdfbfa'
You can trace these jobs/GUIDs back to the subscription and report through the ReportServer database using the Subscriptions table and its MatchData column (matches the job GUID) and the Catalog table which includes the report data (i.e. linked through the Subscriptions.Report_OID column.
You can use this information to check what's scheduled and based on this schedule your update appropriately.
I haven't tried it myself, but one option could even be to hook into the existing database jobs, but I would approach this with caution; I can't see any issues but maybe it's best not to update any system created jobs like these.

Related

Run SSRS subscription with different parameters

Is there a way to programmatically execute an existing subscription with different report parameters?
So far I execute subscriptions via SQL as follows:
EXEC ReportServer.dbo.AddEvent 'TimedSubscription', '<Subscriptions.SubscriptionID>'
But this seems to only allow me to execute the subscription as-is.
Edit:
I wanted to do this for our existing subscriptions (50+ total).
Manually re-creating each subscription is not feasible.
The first commenter in this article updates the Parameters value in the Subscriptions table via a Stored Procedure before running the AddEvent command:
update Subscriptions
set Parameters=
'<ParameterValues><ParameterValue><Name>Value</Name><Value>' + #value + '</Value></ParameterValue></ParameterValues>'
where SubscriptionID='XXX-XXX-XXX-XXX'
The way I worked through this problem was to set up a data driven subscription on the report that populated the parameters based on the values held within a specifically designed SQL table. I then set up a stored procedure that populated that table with the values that were required and then fired the subscription using AddEvent.
You may run into issues with this approach if you need to run fire the subscriptions more frequently than it takes to produce the report and thus cleaning out the lookup table. If the report isn't that frequent though, you should be fine.
If I'm understanding your question correctly, you could take 2 of the following approaches:
Approach 1
Step 1: Navigate to the report you would like run with different parameters.
Step 2: Select to manage the report
Step 3: Select to Create Linked Report
Step 4: Choose the location where the report can live.
Step 5: For the new linked report, click to manage the report
Step 6: Change the default parameters you'd like passed
Step 7: Create subscription for new linked report.
Approach 2
Step 1: Navigate to the report you would like run with different parameters.
Step 2: Select to manage the report.
Step 3: Create a subscription for the report
Step 3a: While creating subscription, specify what values you want passed.
Hope this helps!

How to View Data In SSRS Reports

I have an SSIS package, There are only two tasks in my SSIS package. One is Execute SQL Task and another one is Data Flow Task. My first task is doing to truncate a table (Table_1) and second task is just load data in truncated table means Table_1. An SSRS report get data from that table means Table_1. My SSIS packages run every hour. when SSIS package running in the same time users has complaining that they are not able to view data in the report. How do I do that my SSIS package start running. Users can able to view data in my Report.
Off the top of my head, have a table that stores values on whether this deal is running or not, doing something like setting a single value to 1 when running and 0 when not running.
Then in your SSRS, instead of a 'SELECT * FROM Table_1', write a stored procedure that has logic to lookup the value in the above table. If 0 return the set normally, if 1 then return some kind of friendly message that data is currently being loaded and the report is not available.

Automation on SQL (MySQL)

I would like to ask a question for connoisseurs of SQL (MySQL, to be specific).
I have a table reservation schedules. And when a customer makes a reservation there is a time to let the client to use my service. Therefore, the reservation that he did have to leave the table reservations.
Once the time limit of use is reached, there is some method (trigger,
I believe), which automatically erase the record of this book on the
table?
If so, can someone give me some idea of ​​how to start my search for it, or it is also totally welcome some help as some more advanced lines of code.
There is also the possibility that this only be possible to be implemented via Server-Side (PHP, ASP ...), which does not believe is so true because SQL is a language very complete (to my knowledge).
Edit1: The problem is that I believe this is a task of the DBMS, so I wanted to leave this responsibility to the MySQL The problem is: how?
A trigger is triggered by either before or after an insert , update or delete event (at least in MySQL according to the docs)
What you want is some sort of scheduled job either through your application be it php, asp.net, etc.. or cron job that calls some sort of SQL script.
So to answer, it can't be done purely with triggers.
You can use SQL jobs, but if the removal logic is to complex to manage it with queries I suggest you to use a PHP script that does all that work for you.
Just write down the data check/remove logic in PHP and set up a simple cron operation for it.
The advantage of this solution is that you can access to your scripts/classes/db providers and save your time and your can log all the operations separately (instead of logging to MySQL logs, no matter what script language you are relying on).
If you have a full control of your server the scheduled operation will look like this (if you want to check your DB entries every day at 00:01):
cat /etc/cron.d/php5
0 1 * * * php /path/to/your/script.php >> /path/to/your_script.log
..otherwise you will have to check the control panel of your hosting account and figure out how to manage
You can create one more column in your table where you will create the expiration date. Then you can on your sql server create the job that will erase all records that have expiration date less than curent date.
CREATE EVENT db_name
ON SCHEDULE EVERY 10 SECOND
DO
DELETE FROM myschema.mytable WHERE expiration_date < NOW()
I hope that will help.

What is the best tool to use to transfer Data from Reporting Database to another?

I have a reporting database and have to transfer data from that to another server where we run some other reports or functions on Data. What is the best way to transfer data periodically like months or by-weekly. I can use SSIS but is there anyway I can put some where clause on what rows should be extracted from the source database? like i only want to extract data for a current month. Please do let me know.
Thanks,
Vivek
For scheduling periodic extractions, I'd leave to that SQL Agent.
As for restricting the results by some condition, that's an easy thing. Instead of this (and you should always use SQL Command or SQL Command From Variable over Table Name/Table Name From Variable as they are faster)
Add a parameter. If you're use OLE DB connection manager, your indicator for a variable is ?. ADO.NET will be #parameterName
Now, wire the filter up by clicking the Parameters... button. With OLE DB, it's ordinal position starting at 0. If you wanted to use the same parameter twice, you will have to list it each time or use the ADO.NET connection manager.
The biggest question you will have to answer is how do I identify what row(s) need to go. Possibilities are endless: query into the target database and find most recent modified date for a table or highest key value. You could create a local table that tracks what's been sent and query that. You could perform an incremental load / ETL Instrumentation to identify new/updated/unchanged rows, etc.

weekly Automatic running sql server script

I have sql server script and i want to automatic run it on the database every week.
any help.
i tried sql server agent job but i have alot of data bases on my server and i should make step to every database and it will run in the same day and same time.
You were on the right track, in management studio:
(1) Find SQL Agent and right click and select Job.
(2) Give you job a name and description and then choose the Steps option on the left
(3) In the Step options you can name your step, insert your script code, AND select which database you want the job to be performed on.
(4) Next go to the Schedules option on the left and designate how often you want the job to run (pretty self-explanatory)
(5) The Alerts, Notifications, etc options should also be utilized if you want to be informed on failure/success/etc.
That's it pretty much.
If you want one job with one step that performs the same action on every database (or perhaps a subset of databases), consider using system procedure sp_msForEachDB. I spelled out one way to use this in this prior answer.