我正在尝试使用SQL Server导入向导将平面文本文件导入SQL Server。
看起来这应该很简单。文本文件以制表符分隔,没有任何异常。
当我在向导中预览数据时,一切看起来都还可以。我检查了列映射,并且所有数据行都已启动,数据类型似乎都没问题。
但是当我运行它时,这是我收到的错误消息:
Copying to [dbo].[my_table] (Error) Messages
Error 0xc0202009: Data Flow Task: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Invalid character value for cast specification".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Invalid character value for cast specification".
(SQL Server Import and Export Wizard)
Error 0xc020901c: Data Flow Task: There was an error with input column "touch4_date" (260) on input "Destination Input" (179). The column status returned was: "The value could not be converted because of a potential loss of data.".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "input "Destination Input" (179)" failed because error code 0xC0209077 occurred, and the error row disposition on "input "Destination Input" (179)" 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: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Destination - cm_campaigns" (166) failed with error code 0xC0209029. 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 0xc0047021: Data Flow Task: SSIS Error Code DTS_E_THREADFAILED. Thread "WorkThread0" has exited with error code 0xC0209029. There may be error messages posted before this with more information on why the thread has exited.
(SQL Server Import and Export Wizard)
一些额外的细节......
平面文件只有22行。
在似乎导致问题的列中(“touch4_date”) - 其中19行包含空值,其中3行包含以下值:
7/2/2008
8/25/2008
3/12/2009
数据库是日期时间的列,它允许空值。
其中一个奇怪的方面是平面文件包含其他列,其数据格式为“mm / dd / yyyy”,映射到datetime列,但那些似乎没有导致任何错误?
任何人都可以解释这个问题吗?
非常感谢提前!
答案 0 :(得分:1)
touch4_date列的值无法强制转换为表列类型。
答案 1 :(得分:0)
尝试将平面文件导入到临时表中,并将第4列标记为varchar。然后插入到您的实际表中,但使用case语句。
declare @string varchar(50)
set @string=''
select
case @string
when '' then null
else @string
end as String