简体   繁体   English

自动将 SQL 查询结果导出为 txt 文件到 Azure blob 存储

[英]Export SQL query result as a txt file to Azure blob storage automatically

I am trying to export the result of a query to a container in the Azure blob storage.我正在尝试将查询结果导出到 Azure blob 存储中的容器。 I did much research and it seems there are services that can do this, but they are paid services;我做了很多研究,似乎有服务可以做到这一点,但它们是付费服务; is there any way to automate this without any paid service at all?有没有什么方法可以在没有任何付费服务的情况下实现自动化? I can already push the files from my computer to the storage automatically, but if I could find a way to directly do this it will be great.我已经可以将文件从我的计算机自动推送到存储中,但如果我能找到一种直接执行此操作的方法,那就太好了。 Essentially I want to extract some data on daily basis to the storage and make it possible for a simple download using browsers or from withing Excel本质上,我想每天将一些数据提取到存储中,并可以使用浏览器或使用 Excel 进行简单下载

fictitious Example:虚构示例:

SELECT name, salary FROM dbo.Employees
Export to https://mystorage.blob.core.windows.net/mycontainer/myresults.txt

If you are use on-premise SQL Server and want to run the script which save the query result to Blob Storage automatically, SSIS is the good solution.如果您使用内部部署的 SQL 服务器并希望运行将查询结果自动保存到 Blob 存储的脚本,那么 SSIS 是一个很好的解决方案。 It's free and very effective.它是免费的并且非常有效。

You can ref this tutorial Azure Blob Storage Data Upload with SSIS : it teaches us run a SQL query and upload it to Blob Storage.您可以参考本教程Azure 使用 SSIS 上传 Blob 存储数据:它教我们运行 SQL 查询并将其上传到 Blob 存储。

Then you can schedule run the SSIS package with a SQL Server agent job.然后,您可以安排运行 SSIS package 与 SQL 服务器代理作业。 Ref this document: How to Execute SSIS Packages from SQL Server Agent :参考此文档: 如何从 SQL 服务器代理执行 SSIS 包

  • SSIS is indeed a good choice for implementing ETL processes. SSIS确实是实现ETL流程的不错选择。 The typical process is scheduled to run on a periodic basis.典型过程计划定期运行。 SQL Server Agent is a good tool for executing SSIS packages as well as scheduling jobs to run at the appropriate times. SQL 服务器代理是执行 SSIS 包以及安排作业在适当时间运行的好工具。

You can combine these two documents and achieve your purpose.您可以将这两个文件结合起来,达到您的目的。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM