我試圖在SQL Server 2012中使用BULK INSERT
將數據從文本文件導入到數據庫表中。我正在使用文本文件中的Z
指示符(DOB字段)的UTC日期時間值。但在執行BULK INSERT
時,我收到「數據轉換錯誤」。批量插入日期時間錯誤
任何人都可以幫我嗎?
腳本
CREATE TABLE Info
(
FirstName VARCHAR(40),
LastName VARCHAR(40),
DOB DATETIME
)
BULK INSERT Info FROM 'F:\InfoTextFile.txt' WITH (FORMATFILE='F:\InfoFormatFile.fmt')
的F含量:\ InfoTextFile.txt的
John Smith 1988-08-23T00:00:00.0Z
William Alexander 1987-07-22T00:00:00.0Z
內容 'F:\ InfoFormatFile.fmt'
11.0
3
1 SQLCHAR 0 10 "" 1 FirstName ""
2 SQLCHAR 0 10 "" 2 LastName ""
3 SQLDATETIME 0 22 "\r\n" 3 DOB ""
錯誤:
Msg 4864, Level 16, State 1, Line 2 Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (DOB).
Msg 4832, Level 16, State 1, Line 2 Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 2 The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 2 Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".