Link to home
Start Free TrialLog in
Avatar of vzorn
vzornFlag for United States of America

asked on

SQL procedure call SSRS report

I have a SSRS report I need to run per client.
I would like to run a SQL procedure every hour to check which clients need the report run.
Then be able to run the report for each client and pass the @client parameter.
Possibly place the report in a folder specific to the @client parameter
Is this possible?
Avatar of Jason Yousef
Jason Yousef
Flag of United States of America image

Yes Possible, do you just need to use T-SQL and SSRS or you can involve SSIS too?

Also what do you mean by which clients need the report, can you explain how would you determine that?
Well, I *think* it is possible *IF* you can tell us *how* you can determine when a client needs report run.
Avatar of vzorn

ASKER

Yes I can use SSIS too.
I am querying a linked server to determine if a client's team has been updated within the last hour.
If is has this client needs to have a report generated.  I can create a temporary table to store the clients to send to.  
I just cant quite figure out how to pass a parameter to the SSRS report and tell it where to save.
I was thinking about a central location and SSIS will rename and move or even e-mail ..

is there's a flag in a table on that linked server ?
Avatar of vzorn

ASKER

For the table in the linked server I am looking for a record with a specific eventID within a specific time period.  It is a history/audit table.  It captures new events.  
Alright..
1-create your temp table
2-build your report on that table
3-schedule that report to render as pdf or XLS into a specific directory, also put the schedule as once so it creates the SQL agent job.
4-will create a SSIS package, schedule it every hour to run.

that package will run the SP to check if the flag is in, then will fire the sql agent job for the report, rename and move or email. per your requirement.

let me know which part you need help with?

Avatar of vzorn

ASKER

I need help generating a separate report for each record.
If there are 4 clients who need the report I actually need 4 separate reports.
can you explain more about the records and clients and how do you get their data?
Avatar of vzorn

ASKER

Well I could use a procedure to check for new records and store them in another table.
Then I could update each one as the report is sent out.
I could use a SELECT TOP 1 to pull just one record, create the report, then update that record?
But I would need to have the report renamed before I can get the next report run.
ASKER CERTIFIED SOLUTION
Avatar of Jason Yousef
Jason Yousef
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
can you let me visualize what you'll bring to the temp table? is it information that will be in the report and one of the columns will be the client name for example?

can you share an example or screen shot? so I can be with you in the same page
Avatar of vzorn

ASKER

Yes that process is what I need to do
"loop over the table, pull one row a time, create the report, rename and move, then process the second "
Temp table I would just store the ClientID, DateReportCreated.
I would inner join the data fields, it is quite a bit of data.  
Data fields would contain clientname, address, city, directions, phone, etc.
Cannot share screenshot sorry, sensitive information
Ok, let me know when you;re ready, when you're done, with the SP that populate the table, done built the report over the temp table...so we can take it to the next level...

Avatar of vzorn

ASKER

This worked great.  Created the SSIS package to loop.
1. Checks for first open record and assigns variable.
2. Runs job to print report to folder  for first open record
3. Renames files to match variable
4. Updates record as completed.

Thanks for your help!
Great :)