Solved

Report Manager- Configuring Subscriptions -Max Points!

Posted on 2010-11-18
8
450 Views
Last Modified: 2012-05-10
I have a report that and am going to create subscriptions for .. I have date parameters on this report ; how do I format the dates on the parameter to send the reports at the end of each month for the full month. The dates in the report are in the datetime-calender format ie (between 10/01/2010 and 10/31/2010) Report-Subscription-Screen.doc
0
Comment
Question by:SPLady
  • 4
  • 4
8 Comments
 
LVL 39

Expert Comment

by:lcohan
ID: 34165327
You should enter the dates as you mentioned like 10/01/2010 and 10/31/2010.
But I think this will be good only for this subscription and you will have to do this month by month or create 12 subscriptions – one for each month.
Here’s what I would do instead if this is a monthly report that you want sent out automatically by the subscription let's say on the first day of each month for the whole previous month.
a.      I would create a new SQL stored procedure and use it into a new monthly report and leaving the one with parameters for user to run it ad-hoc if needed.
b.      In the SP I would calculate/assign the beginning/end of each month to variables and use that SP instead of the one with parameters for this purpose.
c.      I would create a monthly report that calls this SP with one subscription to send it out on snapshot updated or schedule whatever you choose.

In this scenario all you need to worry is when you schedule/run the report that calls this SP so you know how to would calculate/assign the beginning/end of each month to variables. I personally would run it immediately after midnight on the first day of each month for the previous month.
0
 
LVL 1

Author Comment

by:SPLady
ID: 34165363
Thank you @Icohan Can you give me an example of that type of SP?
0
 
LVL 39

Expert Comment

by:lcohan
ID: 34165592
CREATE PROCEDURE mth_report
AS
BEGIN
SET NOCOUNT OFF

DECLARE @begindate datetime
DECLARE @enddate datetime
DECLARE @date datetime

SET @date = dateadd (mm, -1, getdate()+13)
SET @begindate = dateadd(m, datediff(m, 0, @date-15), 0)
SET @enddate = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@date),0))
PRINT @date
PRINT @begindate
PRINT @enddate

--then you will use them in a select or even execute the other SP with parameters passing the two dates
select * from my_table where report_date between @begindate and @enddate
exec report_monthly @begindate,@enddate

END
GO

!!!CAUTION that I included getdate()+13 just for you to see the date as it will be on Nov 1st and please remove the +13  from the code in case you want to use it.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:SPLady
ID: 34165728
Nov  1 2010 11:04AM
Oct  1 2010 12:00AM
Oct 31 2010 11:59PM

Thank you! Cool why did I get this error---->Procedure Rpt has no parameters and arguments were supplied.

No rows affected.
(1 row(s) returned)
@RETURN_VALUE =
Finished running [dbo]

and the newbie question/ not sure of terminology :0) - How do I wire it to the report manager or call it?
0
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 34165857
The error is most likely because you don't have a exec report_monthly SQL sp with @begindate,@enddate parameters....

Instead "report_monthly" you can plug in there the name of your stored procedure that the report with parameters is calling.

As far as coding....hmmm that's something you will need to learn or get someone to do it for you.
Briefly, you should create a new SSRS report to execute this new SP, then under execution you will schedule it to run on each 1st day of each month, then add a subscription to send it out on snapshot updated or at the desired time.

Hope this helps...
0
 
LVL 1

Author Closing Comment

by:SPLady
ID: 34165946
Thank you!
0
 
LVL 1

Author Comment

by:SPLady
ID: 34166054
How do I refer to the report I want to run in this portion ----> (does it have to call another SP?) then you will use them in a select or even execute the other SP with parameters passing the two dates
select * from my_table where report_date between .... ...
0
 
LVL 39

Expert Comment

by:lcohan
ID: 34166392
Here, use the code below to create a new SP (same as I posted above) and change its name into something meaningfulfor you. Inside it please replace "your_existing_report_code" with the actual sp name of your current SSRS report, or paste the SQL query code that your SSRS is running and use  @begindate and@enddate in it.

Execute (store) the Stored procedure in the same database you have your data and create a new SSRS report to run it each month as mentioned above. Here's the code:

CREATE PROCEDURE mthy_report
AS
BEGIN
SET NOCOUNT OFF

DECLARE @begindate datetime
DECLARE @enddate datetime
DECLARE @date datetime

SET @date = dateadd (mm, -1, getdate()+13)
SET @begindate = dateadd(m, datediff(m, 0, @date-15), 0)
SET @enddate = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@date),0))

exec your_existing_report_code @begindate,@enddate

END
GO
 


0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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…

856 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