如果您有权访问报告数据库,则可以轻松地将订阅参数更新为列表中的新键,并运行发送该订阅的作业。基本上,您可以执行一些任务来获取处理的最后一个密钥、查找所有新密钥、更新订阅、触发每个新密钥的订阅作业。
这是我的一些查询,您可以在其中找到订阅和作业名称之间的链接:
SELECT
s.subscriptionid,
ISNULL(c_p.Name, c.Name) AS Report,
msdb.dbo.sysjobs.name AS SQLAgentName,
CASE WHEN c.Type = 4 THEN c.Name + ' [' + s.Description + ']' ELSE s.Description end AS Description,
MAX(s.LastRunTime) AS LastRun, s.LastStatus,
s.DeliveryExtension, c.Description AS HowOften, msdb.dbo.sysjobs.job_id, msdb.dbo.sysjobs.enabled
FROM dbo.Catalog AS c
LEFT JOIN dbo.Catalog AS c_p
ON c_p.ItemID = c.LinkSourceID AND c.Type = 4
INNER JOIN dbo.Subscriptions AS s
ON s.Report_OID = c.ItemID
INNER JOIN dbo.ReportSchedule
ON c.ItemID = dbo.ReportSchedule.ReportID
AND s.SubscriptionID = dbo.ReportSchedule.SubscriptionID
INNER JOIN msdb.dbo.sysjobs
ON CAST(dbo.ReportSchedule.ScheduleID AS varchar(100))
= CAST(msdb.dbo.sysjobs.name AS varchar(100))
where msdb.dbo.sysjobs.enabled = 1
GROUP BY s.subscriptionid, c_p.Name, c.type, c.Name, msdb.dbo.sysjobs.name, s.Description, s.LastStatus, s.DeliveryExtension, c.Description, msdb.dbo.sysjobs.job_id, msdb.dbo.sysjobs.enabled
修改 dbo.Subscription 参数并调用
exec msdb.dbo.sp_start_job @job_name = @JobName;
以完成您的任务。