简体   繁体   English

Azure SQL DB-从Azure SQL导出数据文件(.csv)

[英]Azure SQL DB - data file export (.csv) from azure sql

I am new to Azure SQL. 我是Azure SQL的新手。 We have a client db which is in Azure SQL. 我们有一个位于Azure SQL中的客户端数据库。 We need to set up a process automation which extract query results to .CSV files and load it in our server (on premise SQL server 2008 R2). 我们需要设置流程自动化,将查询结果提取到.CSV文件并将其加载到我们的服务器中(在内部SQL Server 2008 R2中)。

What is the best method to generate csv files from Azure sql and make it accessible for the on premise server? 从Azure sql生成csv文件并使本地服务器可访问的最佳方法是什么?

Consider using simple bcp from the on prem environment save the results to csv and then load the csv into the on prem server. 考虑从on prem环境中使用简单的bcp ,将结果保存到csv,然后将csv加载到on prem服务器中。

You can also use SSIS to implement an automated task. 您还可以使用SSIS来实现自动化任务。

Though I would like to know why you need the intermediate csv file? 虽然我想知道为什么需要中间的csv文件? you can simply just copy data between databases (cloud -> On prem) with a scheduled SSIS package. 您只需使用计划的SSIS包在数据库之间复制数据(云->本地)即可。

Honestly the best in terms of professional approach is to use Azure Data Factory and installation of Integration Runtime on the on premises. 老实说,就专业方法而言,最好的方法是在内部使用Azure数据工厂和Integration Runtime的安装。

You of course can use BCP but it will be cumbersome in the long run. 您当然可以使用BCP,但从长远来看,这将很麻烦。 A lot of scripts, tables, maintenance. 很多脚本,表格,维护。 No logging, no metrics, no alerts... Don't do it honestly. 没有日志记录,没有指标,没有警报...不要诚实地做。

SSIS is another option butin my opinion it takes more effort than ADF solution. SSIS是另一种选择,但我认为它比ADF解决方案需要更多的精力。

Azure Data Factory will allow you to do this in professional way using user interface with no coding. Azure数据工厂将允许您使用用户界面以专业方式完成此操作,而无需编写代码。 It also can be parametrized so you just change name of table name parameter and suddenly you are exporting 20, 50 or 100 tables at ease. 还可以对其进行参数化,因此您只需更改表名称参数的名称,然后突然就可以轻松导出20、50或100个表。

Here is video example and intro into data factory if you want to see quick overview. 如果您想快速浏览一下,这里是视频示例,并介绍了数据工厂。 In this overview there is also demo which imports CSV to Azure SQL, you can just change it a little bit to make Azure SQL -> CSV and CSV > SQL server or just directly Azure SQL > SQL server. 在此概述中,还有一个将CSV导入Azure SQL的演示,您只需对其稍作更改即可使Azure SQL-> CSV和CSV> SQL Server或直接成为Azure SQL> SQL Server。

https://youtu.be/EpDkxTHAhOs https://youtu.be/EpDkxTHAhOs

It really is straightforward. 这确实很简单。

If you have on-prem SQL access then a simple SSIS package is probably the quickest and easiest way to go. 如果您具有本地SQL访问权限,则简单的SSIS包可能是最快,最简单的方法。 If your source is Azure SQL and the ultimate destination is On-Prem SQL, you could use SSIS and skip the CSV all together. 如果源是Azure SQL,而最终目标是本地SQL,则可以使用SSIS并一起跳过CSV。

If you want to stick to an Azure PAAS solution you could consider using Azure Data Factory. 如果要坚持使用Azure PAAS解决方案,可以考虑使用Azure数据工厂。 You can setup a gateway to access the on-prem SQL server directly or if you really want to stick to a CSC then look into using a Logic App. 您可以设置网关以直接访问本地SQL Server,或者如果您确实想坚持使用CSC,则可以使用Logic App进行调查。

Azure Data Factory is surely option. 当然可以选择Azure数据工厂

Simple solution would be pyodbc driver with little bit of python. 一个简单的解决方案是只有一点点python的pyodbc驱动程序。 https://docs.microsoft.com/en-us/sql/connect/python/python-driver-for-sql-server?view=sql-server-2017 https://docs.microsoft.com/en-us/sql/connect/python/python-driver-for-sql-server?view=sql-server-2017

You can also try sqlcmd and bit of powershell or bash on top. 您也可以在上面尝试sqlcmd和一些powershellbash https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017 https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017

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

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