Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Report sent via email when user presses a button

Posted on 2007-03-21
4
Medium Priority
?
508 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 2000 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

Independent Software Vendors: 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

1. Set up your parameter at the report level as usual, check the box Multi-value, and set the Data Type to String 2. Set the Stored Procedure Parameter to varchar(max)  --<---- This part here is the key to it's success Example:    @cst_key var…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 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