Solved

SQL Report sent via email when user presses a button

Posted on 2007-03-21
4
501 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
  • 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Hi, I am very much excited today since I'm going to share something very exciting Tool used for Analytical Reporting and that's nothing but MICROSTRATEGY. Actually there are lot of other tools available in the market for Reporting Such as Co…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now