简体   繁体   English

SQL Server批量插入:批量加载数据转换错误(类型不匹配或指定代码页的字符无效)

[英]SQL Server BULK INSERT: Bulk load data conversion error (type mismatch or invalid character for the specified codepage)

Here is my table definition: 这是我的表定义:

CREATE TABLE BillTexts 
(
    SessionNum INT,
    Name VARCHAR(200),
    Part INT,
    BillText VARCHAR(MAX)
)

Here is the code I am using to bulk insert it. 这是我用来批量插入的代码。 I have used the funky delimiters to make sure there are no conflicts (commas, newlines) with what's inside the billtext column. 我使用了时髦的定界符来确保与billtext列中的内容没有冲突(逗号,换行符)。

BULK INSERT BillTexts
FROM texts.csv
WITH (
    DATAFILETYPE = 'char',
    FIELDTERMINATOR = '¬',
    ROWTERMINATOR = '[]{}\r\n'
)

Here is the first couple of lines of my text file. 这是我的文本文件的前几行。

112¬hconres1¬1¬"A whole bunch of text"[]{} 
112¬hconres1¬2¬"Another whole bunch of text"[]{}

On every line (including lines 1 through 10) I get the error 在每行(包括第1行到第10行)上,我都会收到错误消息

Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 (SessionNum) 第1行第1列(SessionNum)的批量加载数据转换错误(类型不匹配或指定代码页的字符无效)

Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 2, column 1 (SessionNum) 第2行第1列(SessionNum)的批量加载数据转换错误(类型不匹配或指定代码页的字符无效)

I honestly have no idea why it's failing to insert. 老实说,我不知道为什么它无法插入。 As far as I know this is the only way I can get this data into the table (there is a lot of it). 据我所知,这是将数据放入表中的唯一方法(有很多)。

I don't have an answer, but I have a line of attack: break it down into smaller problems. 我没有答案,但是有一条攻击线:将其分解为较小的问题。

Start with a set of data that only contains, say, 5 rows of data. 从一组仅包含5行数据的数据开始。 If that still fails, break it down to 5 rows with 1 column--this will test your row delimiters. 如果仍然失败,请用1列将其分解为5行-这将测试您的行定界符。 Then, add the second column back in, to test the column delimiters. 然后,重新添加第二列,以测试列定界符。 Next, add all but the "blob" column, test, and then add the blob back in. Possibly, load just the blob as a single column dataset, see how that works. 接下来,添加除“ blob”列之外的所有列,进行测试,然后重新添加blob。可能的是,仅将blob加载为单列数据集,看看其工作原理。

Note that you'll need to create specific testing tables for all of the above. 请注意,您需要为上述所有步骤创建特定的测试表。

Looking at the problem from multiple perspectives should help narrow down what's going on--what works, what doesn't. 从多个角度看待问题应该有助于缩小正在发生的事情-哪些有效,哪些无效。 (The files are single-byte, not double-byte, right?) (文件是单字节的,不是双字节的,对吗?)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 批量加载数据转换错误(类型不匹配或指定代码页的字符无效) - Bulk load data conversion error (type mismatch or invalid character for the specified codepage) 第 1 行第 4 列(年份)的批量加载数据转换错误(指定代码页的类型不匹配或无效字符) - Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 4 (Year) 第 1 行第 1 列 (ID) 的批量加载数据转换错误(指定代码页的类型不匹配或无效字符) - Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 (ID) CSV 重要失败 - 批量加载数据转换错误(指定代码页的类型不匹配或无效字符) - CSV impor failing - Bulk load data conversion error (type mismatch or invalid character for the specified codepage) 批量加载数据转换错误(指定代码页的类型不匹配或无效字符) - Bulk load data conversion error (type mismatch or invalid character for the specified codepage) 使用BULK INSERT SQL SERVER的乐趣 - 为指定的代码页输入不匹配或无效字符 - Fun with BULK INSERT SQL SERVER - type mismatch or invalid character for the specified codepage SQL Server批量插入-“批量加载数据转换错误” - SQL Server bulk insert - “Bulk load data conversion error” 由于文件(类型不匹配或指定代码的字符无效),无法批量加载 - Cannot bulk load because the file(type mismatch or invalid character for the specified code) 批量加载数据转换错误 - Bulk load data conversion error SQL大容量插入-不匹配 - SQL Bulk Insert — Mismatch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM