[英]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:
编写批处理文件的其他替代方法是:
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);
MyTable
has to have identical columns (or it can be a view against a table that yields identical columns) MyTable
必须具有相同的列(或者可以是针对产生相同列的表的视图) ds_blob
is an external data source which needs to be created beforehand ( https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-data-source-transact-sql ) ds_blob
是需要预先创建的外部数据源( https://docs.microsoft.com/zh-cn/sql/t-sql/statements/create-external-data-source-transact-sql ) 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.