可以在SSIS中实现运行总计,无需任何手动编码



我有必须做运行总计的场景,我可以通过纯T-SQL或脚本任务来实现这一点。但我想避免手工编码,并使用 ETL 工具功能。是否可能以及如何。

我有表格余额

SELECT '00000001' AS [AccountNo], CONVERT(date,'20080828') AS [Date],10 AS [DailyMovement]
INTO   balances
UNION  ALL
SELECT '00000001' AS [AccountNo], CONVERT(date,'20080829') AS [Date],5 AS [DailyMovement]
UNION  ALL
SELECT '00000001' AS [AccountNo], CONVERT(date,'20080830') AS [Date],7 AS [DailyMovement]
UNION  ALL
SELECT '00000002' AS [AccountNo], CONVERT(date,'20080828') AS [Date],8 AS [DailyMovement]
UNION  ALL
SELECT '00000002' AS [AccountNo], CONVERT(date,'20080829') AS [Date],6 AS [DailyMovement]

我像这样被毁了。

SELECT b1.[AccountNo]
,      b1.[Date]
,      b1.[DailyMovement]
,      SUM(b2.[DailyMovement]) AS [RunningTotal]
FROM   balances b1
INNER  JOIN balances b2 ON  b1.[AccountNo] = b2.[AccountNo]
                           AND b1.[Date] >= b2.[Date]
GROUP  BY b1.[AccountNo],b1.[Date],b1.[DailyMovement]; 

想要在没有手动编码的情况下在 SSIS 中执行此操作

您是否尝试添加查询

SELECT b1.[AccountNo]
,      b1.[Date]
,      b1.[DailyMovement]
,      SUM(b2.[DailyMovement]) AS [RunningTotal]
FROM   balances b1
INNER  JOIN balances b2 ON  b1.[AccountNo] = b2.[AccountNo]
                           AND b1.[Date] >= b2.[Date]
GROUP  BY b1.[AccountNo],b1.[Date],b1.[DailyMovement]; 

到一个 oledbsource 将其用作 Source,然后直接将其指向 oledbdestination?

不。 并非没有手工编码的东西。 我发现运行总计的最佳选择是 SQLServerCentral 的 Jeff Moden 的这篇文章

相关内容

  • 没有找到相关文章

最新更新