我的SSIS中的Send mail task
(基于Visual Studio 2008)软件包(CodaRawDataUpload.dtsx)未被触发(它根本不会变为绿色,黄色或红色)。
“Row Check
”命令中的SQL返回0
或1
,并定义为int
。结果rows_identical
被定义为具有Int32
数据类型的变量。
SQL看起来像这样:
DECLARE
@current_month DATETIME,
@current_year DATETIME,
@current_year_final AS INT,
@previous_period_final VARCHAR(2),
@test_period AS VARCHAR (2),
@previous_period_final_2 VARCHAR(2)
SET @current_month = DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()),0)
SET @current_year = DATEADD(YEAR,DATEDIFF(YEAR,0,GETDATE()),0)
SET @current_year_final = CASE WHEN LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),4),2) = '01' THEN LEFT(CONVERT(VARCHAR,@current_year,112),4)-1 ELSE LEFT(CONVERT(VARCHAR,@current_year,112),4) END
SET @previous_period_final = CASE
WHEN CAST(LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),4),2) AS INT) - 1 BETWEEN 10 AND 11 THEN CAST(CAST(LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),4),2) AS INT) - 1 AS VARCHAR) -- Type Varchar
WHEN CAST(LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),3),1) AS INT) - 1 BETWEEN 1 AND 8 THEN '0' + CAST(CAST(LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),3),1) AS INT) - 1 AS VARCHAR)
WHEN CAST(LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),4),2) AS INT) - 1 = 9 THEN '09'
WHEN LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),4),2) = '01' THEN '12'
ELSE 'Invalid formula' END
SET @previous_period_final_2 = CAST(LEFT(RIGHT(CONVERT(VARCHAR, GETDATE(),112),4),2) AS INT) - 1
select CAST(CAST(case when count_rows_raw = count_rows_facts then 1 else 0 end as bit)as int) as rows_identical
--,SQL_VARIANT_PROPERTY(CAST(CAST(case when count_rows_raw = count_rows_facts then 1 else 0 end as bit)as int),'BaseType') -- ### EXCELLENT WAY TO RETRIEVE DATATYPE ###
from
(
select
(
select SUM(#rows_facts) as #rows_facts from
(
select COUNT(ID) as #rows_facts, 'finalized_entries_facts_table' as type from facts_reporting where DateID in (select DateID from dim_date as date
left join dim_month month on month.MonthID = date.MonthID
left join dim_year year on year.YearID = date.YearID
where year.YearName = CAST(@current_year_final AS Varchar) and month = @previous_period_final_2)
and SourceID IN (select SourceID from dbo.dim_source where Source = 'CODA')
union
select COUNT(ID) as #rows_facts, 'missing_entries_facts_table' as type from missing_ids_CODA_raw where DateID in (select DateID from dim_date as date
left join dim_month month on month.MonthID = date.MonthID
left join dim_year year on year.YearID = date.YearID
where year.YearName = CAST(@current_year_final AS Varchar) and month = @previous_period_final_2)
and SourceID IN (select SourceID from dbo.dim_source where Source = 'CODA')
) as rows
) as count_rows_facts,
(
select COUNT(doccode) as #rows_raw from CodaRaw where yr_period = CAST(@current_year_final AS Varchar)+'/'+CAST(@previous_period_final_2 AS Varchar)
) as count_rows_raw
)
as row_checks
至于Precedence Constraint Editor我尝试了两种方式(值= 0或值= 1)但是从不触发发送邮件任务:
为什么呢?这有什么问题?