0

我正在尝试批量插入 sql server 2008,但在 Date 列上出现错误。

    SET DATEFORMAT dmy

BULK
INSERT CustomSelection
FROM 'c:\test.csv'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

第 2 行第 1 列(日期)的批量加载数据转换错误(指定代码页的类型不匹配或无效字符)。

这是 .csv 文件中的日期:18/08/2012。任何想法如何解决这个问题?

4

1 回答 1

0

your date format is invalid thats way sql server giving error .

To solve these type of issue you have to follow following steps : 1. Import csv in database table , table column must be varchar it should not be datetime . 2. Then run following query to find invalid dates .

select inserteddate from table where isdate(inserteddate) = 0 

3. then update those date manually or by update query something like :

UPDATE TABLE1
SET INSERTEDDATE = CONVERT(DATETIME , '18/08/2012' , 105)
WHERE INSERTEDDATE = '18/08/2012'
于 2013-07-13T10:07:34.527 回答