SSIS多条件拆分

时间:2014-12-19 16:08:19

标签: ssis

我是创建SSIS包的新手。我的数据库上有一个表,其中包含我需要的所有信息。我正在尝试创建一个SSIS包,它将按部门拆分数据,然后根据日期范围按月拆分。

我要创建包以按部门将数据拆分为单独的Excel电子表格....但是,我不知道如何根据日期范围进一步推出包以按月分配条件作为部门。非常感谢任何帮助。

SELECT
    Department
,   [Transaction Type]
,   Quantity
,   [Date/Time]
,   CASE
         when (cast([Date/Time] as Date)  >= '2014-06-01' and cast([Date/Time] as Date) < '2014-07-01') then 'June'
         when (cast([Date/Time] as Date)  >= '2014-07-01' and cast([Date/Time] as Date) < '2014-08-01') then 'July'
         when (cast([Date/Time] as Date)  >= '2014-08-01' and cast([Date/Time] as Date) < '2014-09-01') then 'Aug'
         when (cast([Date/Time] as Date)  >= '2014-09-01' and cast([Date/Time] as Date) < '2014-10-01') then 'Sept'
         when (cast([Date/Time] as Date)  >= '2014-10-01' and cast([Date/Time] as Date) < '2014-11-01') then 'Oct'
         when (cast([Date/Time] as Date)  >= '2014-11-01' and cast([Date/Time] as Date) < '2014-12-01') then 'Nov'
         when (cast([Date/Time] as Date)  >= '2014-12-01' and cast([Date/Time] as Date) < '2015-01-01') then 'Dec'
         else '' 
    END as Months
FROM [dbo].[DETAIL_DATA]

基本上,我想创建一个SSIS包,将数据按部门和月份放入excel电子表格中。有可能吗?

1 个答案:

答案 0 :(得分:2)

您可以尝试使用for循环或foreach循环任务,这将允许您遍历每个部门和每月导出它们。你可以从一个部门和一个月开始,然后尝试在部门内部进行概括,保持月份固定;并最终将这几个月推广到另一个循环中。

重点是,当我看到请求时,您需要循环而不是条件分割。