1

I have a data driven subscription which delivers a report to an email alias at specific time. In a subscription query:

select WorkProjectionReportTime,WorkProjectionReportToMailAlias,
'Work Projection Report for the period ' + CONVERT(varchar(10),GETDATE()-31,101)+ ' to '+CONVERT(varchar(10),GETDATE()-1,101) as Subject,
CONVERT(varchar(10),GETDATE()-31,101) as FromDate,CONVERT(varchar(10),GETDATE()-1,101) as ToDate, 60 as WO, 
'Please see the attachment for the details' as body
from tblConfig
Pivot ( MAX(cValue) for cKey in (WorkProjectionReportTime,WorkProjectionReportToMailAlias) ) as xyz

So by query I get all the required fields, Email To, Time, report parameters.

I want to use the time parameter to schedule report. e.g. if time is 9:30 the report should be mailed at 9:30 AM etc. I want to achieve this from SQL or database front and not from C#. How to achieve this?

4

2 回答 2

1

结合上面建议的调度表,您可以使用以下命令通过 TSQL 发送报告,使用 @report_path 作为参数:

SELECT 'exec ReportServer.dbo.AddEvent @EventType=''TimedSubscription'', 
             @EventData=''' + CONVERT(VARCHAR(max), rs.SubscriptionID) + ''''
FROM   ReportServer.dbo.Catalog c,
       ReportServer.dbo.ReportSchedule rs,
       ReportServer.dbo.Schedule s
WHERE      rs.ReportID = c.ItemID
       AND rs.ScheduleID = s.ScheduleID
       AND c.path = @report_path
       AND s.RecurrenceType = 1 -- only the ones with the regular scheduling disabled
于 2012-10-24T17:34:53.150 回答
0

您可以创建每分钟运行的作业并检查是否有报告要发送和发送。但这意味着您将有最多 1 分钟的延迟 +“您的报告运行需要多长时间”。

此外

  1. 您可以将报告发送放在服务代理中,它将确保报告异步发送到您的计划检查器作业。

或者

  1. 为报告发送创建排队表,主作业将向其插入发送请求。此外,您可以有 5 个作业来读取 1-2 个请求并发送它们,但在这种情况下,您会延迟作业计划。

希望这可以帮助。

于 2012-10-24T16:05:31.647 回答