我有三个问题:
select count(*) from facttable;
Select distinct customerkey from facttable;
select distinct productkey from facttable;
我需要使用SSIS将这三个查询的结果放在csv文件的同一张表中,
输出将是:
行数:100(仅示例) customerid列表:12ff
15kif 产品ID列表:mokd125
oki89
如何将结果放在同一个csv表中?
答案 0 :(得分:0)
将您的提取查询更改为:
select 'Number of records: ' + cast(count(*) as varchar(50)) as data from facttable
union all select ''
union all select 'List of Customer ID:'
union all
Select distinct cast(customerkey as varchar(50)) from facttable;
union all select ''
union all select 'List of Product ID:'
union all
select distinct cast(productkey as varchar(50)) from facttable;
这将为您提供可以写入文本文件的单列数据集。
UNION ALL在这里至关重要,因为它需要所有记录。 UNION摆脱了重复。