批量插入问题

扫码查看
本文介绍了批量插入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据从此链接插入到我的SQL Server

I am trying to insert the data from this link to my SQL serverhttps://www.ian.com/affiliatecenter/include/V2/CityCoordinatesList.zip

我创建了表

CREATE TABLE [dbo].[tblCityCoordinatesList](
    [RegionID] [int] NOT NULL,
    [RegionName] [nvarchar](255) NULL,
    [Coordinates] [nvarchar](4000) NULL
) ON [PRIMARY]

我正在运行以下脚本来进行批量插入

And I am running the following script to do the bulk insert

BULK INSERT tblCityCoordinatesList
FROM 'C:\data\CityCoordinatesList.txt'
WITH
(
    FIRSTROW = 2,
    MAXERRORS = 0,
    FIELDTERMINATOR = '|',
    ROWTERMINATOR = '\n'
)

但批量插入失败出现以下错误

But the bulk insert fails with following error

Cannot obtain the required interface ("IID_IColumnsInfo") from OLE DB provider "BULK" for linked server "(null)".

当我在Google上搜索时,我发现了几篇文章说该问题可能与RowTerminator有关,但我尝试了所有方法例如/ n / r,/ n等,但没有任何效果。

When I google, I found several articles which says the issue may be with RowTerminator, but I tried everything like /n/r, /n etc, but nothing is working.

有人可以帮助我将此数据插入到我的数据库中吗?

Could anyone please help me to insert this data into my database?

推荐答案

尝试 ROWTERMINATOR ='0x0a'
应该可以。

Try ROWTERMINATOR = '0x0a'.it should work.

这篇关于批量插入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 14:45
查看更多