[英]Bulk insert CSV file from Azure blob storage to SQL managed instance
I have CSV file on Azure blob storage.我在 Azure blob 存储上有 CSV 文件。 It has 4 columns in it without headers and one blank row at starting.
它有 4 列,没有标题,开始时有一个空白行。 I am inserting CSV file into SQL managed instance by
bulkinsert
and I have 5 columns in the database table.我通过
bulkinsert
将CSV 文件插入到SQL 托管实例中,并且我在数据库表中有5 列。 I don't have 5th column in CSV file.我在 CSV 文件中没有第 5 列。
Therefore it is throwing this error:因此它抛出这个错误:
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 5 (uId2)
第 1 行第 5 列 (uId2) 的批量加载数据转换错误(指定代码页的类型不匹配或无效字符)
As I want to insert that 4 columns from CSV file to table in database and I want that 5th column in table as NULL.因为我想将 CSV 文件中的 4 列插入到数据库中的表中,并且我希望表中的第 5 列为 NULL。
I am using this code:我正在使用此代码:
BULK INSERT testing
FROM 'test.csv'
WITH (DATA_SOURCE = 'BULKTEST',
FIELDTERMINATOR = ',',
FIRSTROW = 0,
CODEPAGE = '65001',
ROWTERMINATOR = '0x0a'
);
Want that 5th row as NULL
in database table, if there are 4 columns in CSV
file.如果
CSV
文件中有 4 列,则希望数据库表中的第 5 行为NULL
。
Sorry, we achieve that in bulk insert.抱歉,我们是通过批量插入实现的。 None of other ways according my experience.
根据我的经验,没有其他方法。
Azure SQL managed instance is also not supported as dataset in Data Factory Data flow . Azure SQL 托管实例也不支持作为数据工厂数据流中的数据集。 Otherwise we can using Data Flow derived column to create a new column to mapping to the Azure SQL database.
否则,我们可以使用数据流派生列创建一个新列以映射到 Azure SQL 数据库。
The best way is that you editor your csv file: just add new column as header in you csv files.最好的方法是编辑 csv 文件:只需在 csv 文件中添加新列作为标题。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.