在SSIS 2012(Foreach ETL)中通过Excel文件循环的问题

时间:2017-12-13 11:03:19

标签: sql-server excel ssis etl ssis-2012

我正在尝试在本地计算机上的目录中处理Excel文件(2007 .XLSX)。已经出现了许多问题,我将列出这些问题。在此之前,让我解释一下我想做什么,以及我如何设置和迄今为止的所有尝试。

设置

  • Microsoft Visual Studio 2012
  • Microsoft Windows 7(32位)

目标

创建一个简单的ETL来遍历文件夹中的Excel文件,并将数据加载到SQL服务器表中。

当前尝试

注意:我非常熟悉编程,特别是循环,但是在SSIS中,我很难获得甚至被读取的Excel文件。

我已经尝试过并且正在执行以下操作:

  • 创建了一个包
  • 创建了一个FOREACH循环容器任务

FOREACH循环任务

  • 设为Foreach文件枚举器
  • Expression将Directory分配给具有目录值的变量(' C:\ Users \ Me \ Desktop \ Excels \')
  • 在变量映射下,我已在索引0
  • 指定了一个变量
  • 设置为使用文件和扩展程序
  • 目前我正在查看所有文件() 注意:我在调试时使用watch来确定变量是否已填充。现在我尝试了一个表达式任务来构建完整路径,然后再转移到数据流上,并且只使用分配的两个变量。

数据流(在FOREACH循环容器之后)

  • 设置Excel文件来源
  • 设置OLE DB目标

Excel来源(数据流内部为第一项任务)

  • 最初使用其中一个文件设置列(显示预览和输入/输出' s) 注意:显示数据以便连接正常

Excel源连接管理器

  • DELAY VALIDATION = TRUE
  • EXPRESSIONS = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + @[User::excelFullPath] + "Extended Properties='EXCEL 12.0 XML;HDR=YES';"
  • ExcelFilePath = @[User::excelFullPath]
  • FirstRowHasColumnName = TRUE

注意:我尝试过使用连接字符串和excel文件路径属性的组合。我自己尝试过这些。

注意:目前我在文件夹中有两个Excel文件。它们与不同的文件名相同,并且列是相同的。

收到的错误

RUN上的最新错误是:

SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" starting.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Error: 0xC0202009 at Data Flow Task, Excel Source 1 [2]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E37.
Error: 0xC02020E8 at Data Flow Task, Excel Source 1 [2]: Opening a rowset for "MAIN$" failed. Check that the object exists in the database.
Error: 0xC004706B at Data Flow Task, SSIS.Pipeline: "Excel Source 1" failed validation and returned validation status "VS_ISBROKEN".
Error: 0xC004700C at Data Flow Task, SSIS.Pipeline: One or more component failed validation.
Error: 0xC0024107 at Data Flow Task: There were errors during task validation.
Warning: 0x80019002 at Foreach Loop Container: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (6) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (6) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" finished: Failure.
The program '[6272] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).

早些时候收到的另一个错误

SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" starting.
Information: 0x4004300A at Import RAW Excel Data, SSIS.Pipeline: Validation phase is beginning.
Error: 0xC0202009 at Package, Connection manager "Excel Connection Manager": SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available.  Source: "Microsoft Access Database Engine"  Hresult: 0x80004005  Description: "Could not find installable ISAM.".
Error: 0xC020801C at Import RAW Excel Data, Excel Source [2]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
Error: 0xC0047017 at Import RAW Excel Data, SSIS.Pipeline: Excel Source failed validation and returned error code 0xC020801C.
Error: 0xC004700C at Import RAW Excel Data, SSIS.Pipeline: One or more component failed validation.
Error: 0xC0024107 at Import RAW Excel Data: There were errors during task validation.
Warning: 0x80019002 at Foreach Loop Container: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "C:\Users\biadmin\Desktop\0006AssocImport\0006AssocImport\Package.dtsx" finished: Failure.

这些并不是所有收到的错误(我没有记录所有错误)但是目前它只是在一个特定错误上失败。

注意

我看过很多YouTube教程,并阅读了一些概述确切步骤的内容。我已经看到他们在进入数据流任务之前从脚本任务设置连接管理器的地方。我看到一个ConnectionString属性仅设置为包含Excel文件路径的变量。

问题

  1. 我的设置中缺少什么
  2. 配置连接管理器以查看文件的变量后,仍然在Excel Source任务上配置输入和输出,因为此时它显示错误
  3. 在这种情况下SSIS中的开发人员首选项是什么,我更喜欢在配置框(脚本或流程)上看到列映射

0 个答案:

没有答案