简体   繁体   English

将 CSV 文件从 Azure blob 存储批量插入到 SQL 托管实例

[英]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.

相关问题 从 BLOB 批量插入 Azure SQL 说文件无法打开 - Bulk INSERT into Azure SQL from BLOB saying file could not be opened 将 CSV 从 Blob 存储批量加载到 SQL 数据库 - Bulk Loading CSV From Blob Storage to SQL Database 如何通过 SSIS 包从 SQL 托管实例访问 Azure 文件存储 - How to access Azure File Storage from SQL managed instance through SSIS packages 从 Azure Blob 存储读取文件到 Azure SQL 数据库 - read file from Azure Blob Storage into Azure SQL Database 从CSV文件批量插入到MS SQL数据库 - Bulk Insert from CSV file to MS SQL Database 使用批量插入从当前目录加载.csv 文件:SQL 服务器 - Load .csv file from current directory with Bulk Insert: SQL Server 从 csv 文件批量插入 - 忽略有错误的行 - SQL Server - Bulk insert from csv file - Ignore rows with errors - SQL Server SQL Server:从 FTP 服务器批量插入 CSV 文件 - SQL Server: Bulk Insert a CSV file from FTP server 从 Azure Blob 存储批量插入时出现 ERRORFILE 问题 - Issue with ERRORFILE when BULK INSERTing from Azure Blob Storage 从 Azure VM SQL 服务器/数据库到 Azure Blob 存储(CSV/JSON)的近实时副本 - Near real time replica from Azure VM SQL Server/DB into Azure Blob Storage (CSV/JSON)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM