gpt4 book ai didi

sql - BULK INSERT SQL SERVER 的乐趣 - 指定代码页的类型不匹配或无效字符

转载 作者:行者123 更新时间:2023-12-02 16:58:32 25 4
gpt4 key购买 nike

我正在插入如下所示的数据:

   AA00000111   PSNH-OT J, SMITH    03/01/2011  10/11/1957  42  Male    Hartford    NH      Lorazepam   Benzodiazepines C
AA00000151 PSNH-OT BEN, HARRY 03/06/2011 07/18/1969 42 Male Hartford NH Fentanyl Synthetic Opioids C
AA00000151 PSNH-OT URA, HARRISON 03/06/2011 07/18/1969 29 Male Hartford NH Norfentanyl Synthetic Opioids C
AA00000181 PSNH-OT WAYNE, GRIFFON 03/06/2011 09/01/1982 75 Female Hartford NH cTHC (Marijuana metabolite) Illicits C

使用此批量插入:

use RadarDataMining
go

BULK INSERT tblRadarsAC
FROM 'C:\PerfLogs\radars.txt'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
)

我收到这些错误:

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 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 2, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 3, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 4, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 5, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 6, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 7, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 8, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 9, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 10, column 4 (date_tested).
Msg 4864, Level 16, State 1, Line 2
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 11, column 4 (date_tested).
Msg 4865, Level 16, State 1, Line 2
Cannot bulk load because the maximum number of errors (10) was exceeded.
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)".

第四个字段类型是日期

出于某种原因,它不喜欢我的日期字段。我不懂为什么。我做错了什么?

最佳答案

创建一个临时表来处理日期字段指定为 varchar 而不是日期的情况,并查看是否可以批量插入其中。该字段中可能有某种不可打印的字符,因此它不是批量插入的日期。

一旦它是一张 table 。做这样的选择

选择“XX”+field4+“XX”

如果您在 X 和日期之间看到空格,则表明您有一个无法打印的字符。如果你想知道字符是什么,可以使用 ASCII() 函数。

关于sql - BULK INSERT SQL SERVER 的乐趣 - 指定代码页的类型不匹配或无效字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7490542/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com