简体   繁体   English

将Blob数据复制到本地sql表中

[英]copy blob data into on-premise sql table

My problem statement is that I have a csv blob and I need to import that blob into a sql table. 我的问题陈述是,我有一个csv blob,我需要将该blob导入到sql表中。 Is there an utility to do that? 有实用程序可以做到这一点吗?

I was thinking of one approach, that first to copy blob to on-premise sql server using AzCopy utility and then import that file in sql table using bcp utility. 我在想一种方法,首先使用AzCopy实用程序将blob复制到本地sql服务器,然后使用bcp实用程序将该文件导入sql表。 Is this the right approach? 这是正确的方法吗? and I am looking for 1-step solution to copy blob to sql table. 并且我正在寻找将blob复制到sql表的一步骤解决方案。

Regarding your question about the availability of a utility which will import data from blob storage to a SQL Server, AFAIK there's none. 关于您是否有实用程序将数据从Blob存储导入SQL Server的问题,AFAIK没有。 You would need to write one. 您将需要写一个。

Your approach seems OK to me. 您的方法对我来说似乎还可以。 Though you may want to write a batch file or something like that to automate the whole process. 尽管您可能想编写一个批处理文件或类似的文件来自动化整个过程。 In this batch file, you would first download the file on your computer and the run the BCP utility to import the CSV in SQL Server. 在此批处理文件中,您首先将文件下载到计算机上,然后运行BCP实用程序以将CSV导入SQL Server。 Other alternatives to writing batch file are: 编写批处理文件的其他替代方法是:

  1. Do this thing completely in PowerShell. 在PowerShell中完全完成此操作。
  2. Write some C# code which makes use of storage client library to download the blob and once the blob is downloaded, start the BCP process in your code. 编写一些C#代码,该代码利用存储客户端库下载blob,一旦下载了blob,就在您的代码中启动BCP进程。

To pull a blob file into an Azure SQL Server, you can use this example syntax (this actually works, I use it): 要将blob文件拉入Azure SQL Server,可以使用以下示例语法(实际上,我可以使用它):

BULK INSERT MyTable 
FROM 'container/folder/folder/file' 
WITH ( DATA_SOURCE = 'ds_blob',BATCHSIZE=10000,FIRSTROW=2);

The only downside to this mehod is that you have to know the filename beforehand - there's no way to enumerate them from inside SQL Server. 这种方法的唯一缺点是您必须事先知道文件名-无法从SQL Server内部枚举它们。

I get around this by running powershell inside Azure Automation that enumerates blobds and writes them into a queue table beforehand 我通过在Azure自动化内部运行powershell来解决此问题,该枚举枚举了blob并将它们事先写入队列表中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 数据从SQL内部部署迁移到SQL Azure - Data movement from SQL on-premise to SQL Azure 使用CRM本地数据的带子查询和连接变量的SQL查询 - SQL query with subquery and concatenating variable using CRM on-premise data Azure SQL 即服务将服务链接到本地​​ SQL Server - Azure SQL as a service linked services to an on-premise SQL Server Create external table using Polybase on-premise 报错 - Create external table using Polybase on-premise error 如何预先在SQL中为CRM 2011内部部署筛选报表 - How to pre filter reports in SQL for CRM 2011 on-premise 使用本地SQL Server中的OpenRowSet连接到SQL Azure DB - Connect to SQL Azure DB using OpenRowSet from on-premise SQL Server 如何通过从 SQL 服务器(本地)到 Azure SQL 数据库的查询/脚本设置定期迁移 - How to set up recurring migration through queries/script from SQL server(On-premise) to Azure SQL database 如何通过 Azure 中的自托管集成运行时(链接服务)连接到本地 sql 服务器? - How to connect to on-premise sql server through self-hosted Integrated runtime(linked service) in Azure? SQL Server复制表112000+记录和BLOB字段 - SQL Server copy table 112000+ records and a BLOB field 无法打开备份设备 - SQL Server 本地备份数据库到 Azure 存储 - Cannot open backup device - SQL Server on-premise backup database to Azure storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM