我有一个数据驱动的订阅,在特定的时间提供一个电子邮件别名的报告。在订阅查询中:
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因此,通过查询,我得到了所有必需的字段,电子邮件收件人,时间,报告参数。
我想使用time参数来安排报表。例如,如果时间是9:30,报告应该在上午9:30邮寄,等等。我想从SQL或数据库前端实现这一点,而不是从C#。如何做到这一点?
发布于 2012-10-25 01:34:53
结合上面建议的调度表,您可以使用以下内容通过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-25 00:05:32
您可以创建每分钟运行一次的作业,并检查是否有要发送的报告,然后发送这些报告。但这意味着你将会有最多1分钟的延迟+“你的报告运行需要多长时间”。
更多
或
希望这能有所帮助。
https://stackoverflow.com/questions/12947474
复制相似问题