将 sql server 查询输出从 ssis 导出到文本文件,包括列头 [英] Export sql server query output from ssis to text file INCLUDING THE COLUMN HEADERS
问题描述
我一直在尝试将 SqlServer sql 查询(存储过程)的输出导出到文本文件.我使用带有 OLEDB 源和平面文件目标的数据流任务实现了它.
I have been trying to export the output of a SqlServer sql query (stored procedure) to a text file. I achieved it using a Data Flow task with an OLEDB source and a Flat File Destination.
我还想在文本文件中获取列标题和查询结果,但我不知道如何包含列标题.
I would also like to get the Column headers along with the query result in the text file , but I cannot figure out how I can include the column headers.
我想在 SSIS 中动态地执行此操作
I would like to do this dynamically from within SSIS
有人知道怎么做吗?
推荐答案
- OLEDB 源,连接数据库.使用表格或最好使用 SELECT 语句(不是选择 *,正如您所知,我确定).
- 平面文件目的地.将它们连接在一起.在平面文件目标编辑器中,单击新建...选择分隔(例如).给一个文件名.说 C:\temp\a.csv.选中第一个数据行中的列名称.单击左窗格中的列部分.您应该会看到您的列名称.您可以在高级"部分更改这些名称.现在,转到映射列,并映射列.
特别注意:不要在存储过程中使用 select 语句作为数据源.参考:http://www.jasonstrate.com/2011/01/31-days-of-ssis-no-more-procedures-2031/
Special Note: Do not use a select statement in a stored proc as your data source. Ref: http://www.jasonstrate.com/2011/01/31-days-of-ssis-no-more-procedures-2031/
请回复.
这篇关于将 sql server 查询输出从 ssis 导出到文本文件,包括列头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!