Solved

SQL Report sent via email when user presses a button

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hi, In my previous Article  (http://www.experts-exchange.com/Database/Reporting/A_15199-Introduction-to-Microstrategy.html)I discussed some basic understanding of Microstrategy that how we can get in Intro of Microstrategy (MSTR). Now it's tim…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

867 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

15 Experts available now in Live!

Get 1:1 Help Now