首页 文章

SSIS:将数据从Excel源导入SQL Server数据库

提问于
浏览
0

我正在尝试从Excel电子表格导入数据并使用SSIS将其加载到SQL Server数据库中 .

这是我的SQL Server表:

SQL Server table

我收到了一条消息

由于将数据从长度为255的数据流列“CIN”插入到数据库列“CIN”(长度为50),可能会发生截断 .

对于每一列,并在执行后得到以下输出:

SSIS package "C:\Users\Faycal\source\repos\Integration test 2\Integration test 2\Package.dtsx" starting.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "CIN" with a length of 255 to database column "CIN" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "NomClient" with a length of 255 to database column "NomClient" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "DRA" with a length of 255 to database column "DRA" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "DPA" with a length of 255 to database column "DPA" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "TypeAgriculteur" with a length of 255 to database column "TypeAgriculteur" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "RaisonSociale" with a length of 255 to database column "RaisonSociale" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "TypeOrganisme" with a length of 255 to database column "TypeOrganisme" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "NomOrganisme" with a length of 255 to database column "NomOrganisme" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "RegistreCommerce/ODECO" with a length of 255 to database column "RegistreCommerce/ODECO" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "CT/CMV/CDA" with a length of 255 to database column "CT/CMV/CDA" with a length of 50.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "CIN" with a length of 255 to database column "CIN" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "NomClient" with a length of 255 to database column "NomClient" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "DRA" with a length of 255 to database column "DRA" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "DPA" with a length of 255 to database column "DPA" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "TypeAgriculteur" with a length of 255 to database column "TypeAgriculteur" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "RaisonSociale" with a length of 255 to database column "RaisonSociale" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "TypeOrganisme" with a length of 255 to database column "TypeOrganisme" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "NomOrganisme" with a length of 255 to database column "NomOrganisme" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "RegistreCommerce/ODECO" with a length of 255 to database column "RegistreCommerce/ODECO" with a length of 50.
Warning: 0x802092A7 at Data Flow Task, OLE DB Destination [79]: Truncation may occur due to inserting data from data flow column "CT/CMV/CDA" with a length of 255 to database column "CT/CMV/CDA" with a length of 50.
Warning: 0x80049304 at Data Flow Task, SSIS.Pipeline: Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available.  To resolve, run this package as an administrator, or on the system's console.
Information: 0x40043006 at Data Flow Task, SSIS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Data Flow Task, SSIS.Pipeline: Pre-Execute phase is beginning.
Information: 0x4004300C at Data Flow Task, SSIS.Pipeline: Execute phase is beginning.
Error: 0xC0202009 at Data Flow Task, OLE DB Destination [79]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "The statement has been terminated.".
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Cannot insert the value NULL into column 'ClientID', table 'DW.dbo.Client'; column does not allow nulls. INSERT fails.".
Error: 0xC0209029 at Data Flow Task, OLE DB Destination [79]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "OLE DB Destination.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "OLE DB Destination.Inputs[OLE DB Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.
Error: 0xC0047022 at Data Flow Task, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "OLE DB Destination" (79) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (92). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure.
Error: 0xC0209017 at Data Flow Task, Excel Source [2]: Setting the end of rowset for the buffer failed with error code 0xC0047020.
Error: 0xC0047038 at Data Flow Task, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on Excel Source returned error code 0xC0209017.  The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
Information: 0x40043008 at Data Flow Task, SSIS.Pipeline: Post Execute phase is beginning.
Information: 0x4004300B at Data Flow Task, SSIS.Pipeline: "OLE DB Destination" wrote 2032 rows.
Information: 0x40043009 at Data Flow Task, SSIS.Pipeline: Cleanup phase is beginning.
Task failed: Data Flow Task
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\Faycal\source\repos\Integration test 2\Integration test 2\Package.dtsx" finished: Failure.
The program '[16900] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).

我检查了高级编辑器,Excel源输出列和OLE DB目标输入列的长度都为255,但Excel源和OLE DB目标外部列的长度为50,所以我尝试并更改了SSFS中的数据类型,从nvarchar (50)到nvarchar(255)并获得此输出:

SSIS package "C:\Users\Faycal\source\repos\Integration test 2\Integration test 2\Package.dtsx" starting.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Warning: 0x80049304 at Data Flow Task, SSIS.Pipeline: Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available.  To resolve, run this package as an administrator, or on the system's console.
Information: 0x40043006 at Data Flow Task, SSIS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Data Flow Task, SSIS.Pipeline: Pre-Execute phase is beginning.
Information: 0x4004300C at Data Flow Task, SSIS.Pipeline: Execute phase is beginning.
Error: 0xC0202009 at Data Flow Task, OLE DB Destination [79]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "The statement has been terminated.".
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Cannot insert the value NULL into column 'ClientID', table 'DW.dbo.Client'; column does not allow nulls. INSERT fails.".
Error: 0xC0209029 at Data Flow Task, OLE DB Destination [79]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "OLE DB Destination.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "OLE DB Destination.Inputs[OLE DB Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.
Error: 0xC0047022 at Data Flow Task, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "OLE DB Destination" (79) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (92). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure.
Error: 0xC02020C4 at Data Flow Task, Excel Source [2]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
Error: 0xC0047038 at Data Flow Task, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on Excel Source returned error code 0xC02020C4.  The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
Information: 0x40043008 at Data Flow Task, SSIS.Pipeline: Post Execute phase is beginning.
Information: 0x4004300B at Data Flow Task, SSIS.Pipeline: "OLE DB Destination" wrote 2032 rows.
Information: 0x40043009 at Data Flow Task, SSIS.Pipeline: Cleanup phase is beginning.
Task failed: Data Flow Task
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\Faycal\source\repos\Integration test 2\Integration test 2\Package.dtsx" finished: Failure.
The program '[11676] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).

为什么会这样?我该怎么办?

P.S:我是一个完全的菜鸟

1 回答

  • 1

    错误是您无法将NULL ClientID插入Client表 . 检查源数据和列映射 .

    SSIS数据流允许您重定向“错误行”,您可以利用它来加载正确的行并根据您的要求单独记录问题行 .

    可以通过源查询或高级编辑器正确设置源的元数据来解决SSIS中的截断警告 . 另一种方法是使用派生列转换创建列的截断版本,然后映射该列 .

相关问题