gpt4 book ai didi

sql - BCP批量导入在第一行抛出 'Invalid character value for cast specification'

转载 作者:行者123 更新时间:2023-12-03 06:48:14 28 4
gpt4 key购买 nike

我正在尝试使用 BCP 实用程序将数据导入到 Azure SQL。数据文件不是由BCP导出创建的,而是由我创建的。

数据文件的一行如下所示:

61b7d233-b6ee-47df-862f-46adfc487eae;Calcimycin;;;;;;;;enUS;0;1;0;0;MeSH

如您所见,不涉及 DateTime,cause the problem 已知该日期时间。 .

BCP命令:

bcp dbo.Word in Word.txt -c -t; -S auu5nuabcl.database.windows.net -d dbname -U username -P pass -e error.txt

除了不导入数据文件中的第一行之外,导入工作正常。错误文件显示:

#@ Row 1, Column 1: Invalid character value for cast specification @# 61b7d233-b6ee-47df-862f-46adfc487eae  Calcimycin                              enUS    0   1   0   0   MeSH

文件的所有其他行均已正确导入。该文件是由我编写的代码自动创建的,因此数据文件的第一行和其他行没有区别。

导致此问题的原因是什么?

有一个类似但未解答的问题here .

其他信息:

这是 SQL 中的表:

CREATE TABLE skicocat.dbo.Word (
Id uniqueidentifier NOT NULL,
NominativeSingular nvarchar(max) NOT NULL DEFAULT (''),
NominativePlural nvarchar(max) NOT NULL DEFAULT (''),
GenitiveSingular nvarchar(max) NOT NULL DEFAULT (''),
GenitivePlural nvarchar(max) NOT NULL DEFAULT (''),
DativeSingular nvarchar(max) NOT NULL DEFAULT (''),
DativePlural nvarchar(max) NOT NULL DEFAULT (''),
AccusativeSingular nvarchar(max) NOT NULL DEFAULT (''),
AccusativePlural nvarchar(max) NOT NULL DEFAULT (''),
Culture nvarchar(50) NOT NULL DEFAULT ('en-US'),
IsCaseSensitive bit NOT NULL DEFAULT (0),
IsDisplayName bit NOT NULL DEFAULT (0),
IsAmbient bit NOT NULL DEFAULT (0),
Hits bigint NOT NULL DEFAULT (0),
Comment nvarchar(max) NULL DEFAULT (''),
CONSTRAINT PK_Word PRIMARY KEY CLUSTERED (Id)
)

最佳答案

在数据库之间移动数据的最佳文件格式是 native 文件格式 (-n)。因此,请使用 -n 开关而不是字 rune 件 (-c)。人眼无法读取该文件,但此类问题会减少。

bcp dbo.Word out Word.bcp -S someOtherServer -d dbname -U username -P pass -e error.txt -n

bcp dbo.Word in Word.bcp -S auu5nuabcl.database.windows.net -d dbname -U username -P pass -e error.txt -n

关于sql - BCP批量导入在第一行抛出 'Invalid character value for cast specification',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35699472/

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