如何解决 csv 文件导入中的字符串 [DT_STR] 错误

问题描述 投票:0回答:0

我在 csv 文件中从 Sybase DB 导出了一个表及其数据。然后我打算使用 SSMS 18 将它导入到 MSSQL Server 中。

我在 MSSQL Server 中创建了保留相同数据类型的表,如下所示:

CREATE TABLE [dbo].[employee_account](
    [UserID] [int] NOT NULL,
    [debit_acct_no] [varchar](20) NOT NULL,
    [active] [bit] NOT NULL,
    [create_dt] [datetime] NULL,
    [created_by] [varchar](45) NULL,
    [Limit] [numeric](26, 6) NOT NULL,
    [allow_od] [char](1) NOT NULL,
    [allow_bal_enq] [char](1) NULL,
    [scheme_type] [varchar](20) NULL
) ON [PRIMARY]
GO

然后我按照这个步骤:

右键单击数据库 -> 单击任务 -> 导入数据 -> 下一步 -> 选择平面文件作为数据源 -> 等等 ..

它在非字符串(Varchar、char)列上进行标记,并且从 CSV 文件导入失败。

样本数据:

UserID,debit_acct_no,active,create_dt,created_by,Limit,allow_od,allow_bal_enq,scheme_type
1,9876765432,1,20/03/2017 7:55:47.396,HAMIT LAMIL,13388.330000,N,,
1,2345654362,1,20/03/2017 7:56:01.120,HAMIT LAMIL,17715.330000,N,,
1,8797654324,1,20/03/2017 7:56:04.663,HAMIT LAMIL,88185.880000,N,,

我不想将所有其他列转换为 varchar。

即使我取消选中隐藏,问题仍然存在。

当我完成这个过程时,我得到了这个错误:

Error 0xc02020c5: Data Flow Task 1: Data conversion failed while converting column "create_dt" (22) to column "create_dt" (88).  The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
 (SQL Server Import and Export Wizard)
 
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[create_dt]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[create_dt]" 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.
 (SQL Server Import and Export Wizard)
 
Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "Data Conversion 0 - 0" (72) failed with error code 0xC0209029 while processing input "Data Conversion Input" (73). 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.
 (SQL Server Import and Export Wizard)
 
Error 0xc0209017: Data Flow Task 1: Setting the end of rowset for the buffer failed with error code 0xC0047020.
 (SQL Server Import and Export Wizard)

我该如何解决这个问题?

sql-server csv sybase
© www.soinside.com 2019 - 2024. All rights reserved.