我試圖從csv加載數據到SQL表中。大容量加載數據轉換錯誤
我DDL:
CREATE TABLE pcm.dbo.partitiondocumentcount
(
partitionkey NVARCHAR(30) NOT NULL,
documentcount INT NOT NULL,
datetime DATETIME2(3) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_partitiondocumentcount PRIMARY KEY (partitionkey ASC)
)
CREATE NONCLUSTERED INDEX partitionkey_index
ON pcm.dbo.partitiondocumentcount (partitionkey AS
我的文件(我也試過不帶引號,沒有工作以及):
"partition-1",1
"partition-2",1
我的查詢:
BULK INSERT partitionDocumentCount
FROM 'C:\files\pcmInitialConfiguration\partitionCount.csv'
WITH(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
SELECT * FROM partitionDocumentCount
我從DBVisualizer得到錯誤:
15:36:26 [BULK - 0 row(s), 0.008 secs] [Error Code: 4864, SQL State: S0001] Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 2 (documentcount).
15:36:26 [SELECT - 0 row(s), 0.004 secs] Empty result set fetched
... 2 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.012/0.000 sec [0 successful, 1 warnings, 1 errors]
也許你有一個平直行,或是在文件標題? – Jens