触发基于报告的数据输入
Trigger a report based entry of data
我正在使用 MS SQL Server 2008R2
标准版。我正在寻找基于最终值进入某个 table 的最终条目来触发报告。该报告是使用 SQL Server Business Intelligence
Development studio 设计的。
是否可以在不使用数据驱动订阅的情况下执行此操作。数据驱动订阅是 MS SQL Server 2008R2
.
标准版中缺少的一项功能
我有部分解决方案
CREATE TRIGGER tr_Report_INSERT_PHASE_PROC
ON [database].[dbo].[table]
AFTER INSERT
AS
IF EXISTS (SELECT * FROM [database].[dbo].[table] where process_value = 'End Of BATCH' )
BEGIN
EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription',
@EventData='xxxx' -- SubscriptionID from Report Manager URL
END
go
但这会在每次插入时触发,我的 table 有历史记录 process_value = 'End of Batch'。所以我需要在我的条件中添加一个 AND if serial_no = inserted serial_no.
如何找到插入序列号的值?
我会在 table 中添加一个名为 'processed' 的位列。然后更新程序为:
CREATE TRIGGER tr_Report_INSERT_PHASE_PROC
ON [database].[dbo].[table]
AFTER INSERT
AS
IF EXISTS (
SELECT *
FROM [database].[dbo].[table]
WHERE process_value = 'End Of BATCH'
AND processed = 0 -- Only process if there is an unprocessed record
)
BEGIN
EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription',
@EventData='xxxx' -- SubscriptionID from Report Manager URL
-- Mark record as processed
UPDATE [database].[dbo].[table]
SET processed = 1
WHERE process_value = 'End Of BATCH'
AND processed = 0
END
go
我正在使用 MS SQL Server 2008R2
标准版。我正在寻找基于最终值进入某个 table 的最终条目来触发报告。该报告是使用 SQL Server Business Intelligence
Development studio 设计的。
是否可以在不使用数据驱动订阅的情况下执行此操作。数据驱动订阅是 MS SQL Server 2008R2
.
我有部分解决方案
CREATE TRIGGER tr_Report_INSERT_PHASE_PROC
ON [database].[dbo].[table]
AFTER INSERT
AS
IF EXISTS (SELECT * FROM [database].[dbo].[table] where process_value = 'End Of BATCH' )
BEGIN
EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription',
@EventData='xxxx' -- SubscriptionID from Report Manager URL
END
go
但这会在每次插入时触发,我的 table 有历史记录 process_value = 'End of Batch'。所以我需要在我的条件中添加一个 AND if serial_no = inserted serial_no.
如何找到插入序列号的值?
我会在 table 中添加一个名为 'processed' 的位列。然后更新程序为:
CREATE TRIGGER tr_Report_INSERT_PHASE_PROC
ON [database].[dbo].[table]
AFTER INSERT
AS
IF EXISTS (
SELECT *
FROM [database].[dbo].[table]
WHERE process_value = 'End Of BATCH'
AND processed = 0 -- Only process if there is an unprocessed record
)
BEGIN
EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription',
@EventData='xxxx' -- SubscriptionID from Report Manager URL
-- Mark record as processed
UPDATE [database].[dbo].[table]
SET processed = 1
WHERE process_value = 'End Of BATCH'
AND processed = 0
END
go