Solved

SQL Report sent via email when user presses a button

Posted on 2007-03-21
4
506 Views
Last Modified: 2010-04-29
Hello,

I don't need a solution, I just need a starting point.  

When I run a report from SQL report manager I run it for a certain user (userid is a parameter for the report).   I have an application.  What I would like to happen is when a user hits a button in the application the report is sent to them in an email.   How should I do this?  Or can this even be done?

Thanks.
0
Comment
Question by:sarolabelle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:chrismc
ID: 18769578
What I'm about to suggest is probably not going to be supported, advised or encouraged by Microsoft.
Also I've not tried this myself.

My idea is to create a subscription record on the fly in the Subscription table in the ReportServer database.
There is a CreateSubscription stored procedure in there which is obviously what report manager uses.
On reflection, I would suggest actually that Microsoft probably wouldn't have a problem with this as the procedure looks reasonably developer friendly.

There is also a DeleteSubscription to remove it at a later time.

So create the subscription to trigger in a minute or two. And log the Id of the subscription record somewhere, then have a cleanup task overnight, deleting these subscriptions.

Cheers
Chris

0
 

Author Comment

by:sarolabelle
ID: 18775681
Ok, great.  I did research and got as far as your last sentence.   How can I log the id and where?   If I save it in SQL then does the DeleteSubscription(subid) method work inside of SQL or perhaps I should create a service that runs at a certain time?  
0
 
LVL 18

Accepted Solution

by:
chrismc earned 500 total points
ID: 18775783
You need to keep track of the subscription your adding somehow. I'm not sure off the top off my head how you'll do this.

Looking quickly at the CreateSubscription procedure and Subscription table, the SubscriptionId id the field you need to keep track of - It's a GUID so I'm not sure how to grab it best after the insert. I'm sure there are  new features in 2005 to get whats just been inserted.
When you've got the id, just write it away in your own table.

Then write a procedure to run the DeleteSubscription for each SubscriptionId you've recorded and then delete it from your table. Whilst you'd create this as a procedure, you can then set a schedule to run this at an appropriate time. This is all standard SQL stuff, no need for extra services.
The SQL Server Agent is the service that manages the running of schedules.

Cheers
Chris
0
 

Author Comment

by:sarolabelle
ID: 18776292
Thank you!  This was just the little push I needed to get me started!  
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question