简体   繁体   English

将数据从平面文件加载到 Sql 服务器表,并使用 SSIS 导出到 excel

[英]Load data from flat file to Sql Server table and also export to excel using SSIS

Problem Statement : The requirement is straight-forward, which is we have a flat file(csv basically) which we need to load into one of the tables in Sql Server database.问题陈述:要求很简单,即我们有一个平面文件(基本上是 csv),我们需要将其加载到Sql Server数据库中的一个表中。 The problem arises when we have to derive a new column(not present in flat file) and populate this too alongwith rest of the columns from the file.当我们必须派生一个新列(平面文件中不存在)并将其与文件中列的 rest 一起填充时,就会出现问题。 The derivation logic of the new columns is - find the max date of "TransactionDate".新列的推导逻辑是 - 找到“TransactionDate”的最大日期。

The entire exercise is to be performed in SSIS and we were hoping to get it done by using DataFlowTask but stuck on how to derive the new column and then add it to the destination flow.整个练习将在SSIS中执行,我们希望通过使用DataFlowTask来完成,但坚持如何派生新列,然后将其添加到目标流。

Ideas :想法

  1. Use DataFlowTask to read the file and then store it in recordset so that in ControlFlow we would use ScriptTask to read it as DataTable and use LINQ sort-of to determine the max column and push it to another DataFlow to be consumed by Sql table (but this I guess would require creating of tabletype in database which I would avoid)使用DataFlowTask读取文件,然后将其存储在recordset集中,以便在ControlFlow中我们将使用ScriptTask将其读取为DataTable并使用LINQ排序来确定最大列并将其推送到另一个DataFlow以供Sql table使用(但是我想这需要在我会避免的数据库中创建表tabletype
  2. Perform the entire operation in DataFlowTask itself and we would be needing Asynchronous transformation (to get all the data and find out the max value)DataFlowTask本身中执行整个操作,我们需要Asynchronous transformation (获取所有数据并找出最大值)

We are kind of out-of-ideas here and any lead would be much appreciated and do let us know if any further information would be required on this regard.我们在这里有点想法,任何线索将不胜感激,如果在这方面需要任何进一步的信息,请告诉我们。

Run a dataflow task to insert the data to your destination table.运行数据流任务以将数据插入目标表。 Follow that up with an Execute SQL task that calculates the MAX(TransactionDate) based on the values in the table with a NULL (or other new record indicator) MaxTransactionDate.随后执行 Execute SQL 任务,该任务根据表中的值使用 NULL(或其他新记录指标)MaxTransactionDate 计算MAX(TransactionDate)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM