简体   繁体   English

使用SSIS将数据从多个SQL表导出到同一Excel文件中的多个工作表中

[英]Export data from multiple SQL tables into multiple worksheets in the same Excel file using SSIS

I have successfully used SSIS to generate multiple Excel worksheets in the same Excel file where the columns all contained the same type of data. 我已经成功地使用SSIS在同一Excel文件中生成多个Excel工作表,其中所有列均包含相同类型的数据。 I was able to achieve this using suggestions from this link: https://social.msdn.microsoft.com/Forums/en-US/6f4a5b98-6373-4f7e-8d03-0876d0b4b611/loading-data-from-multiple-tables-to-multiple-sheets-of-excel-using-ssis?forum=sqlintegrationservices and which is elaborated on in this link: https://social.msdn.microsoft.com/Forums/en-US/2421d9aa-5347-4f24-a78b-da02eb644f5f/export-sql-server-table-into-multiple-sheets-in-excel?forum=sqlintegrationservices 我可以使用来自此链接的建议来实现此目标: https : //social.msdn.microsoft.com/Forums/en-US/6f4a5b98-6373-4f7e-8d03-0876d0b4b611/loading-data-from-multiple-tables- to-multiple-sheets-of-excel-using-ssis?forum = sqlintegrationservices ,在此链接中对此进行了详细说明: https : //social.msdn.microsoft.com/Forums/en-US/2421d9aa-5347-4f24- a78b-da02eb644f5f /出口-SQL服务器表-到-多张合的Excel?论坛= sqlintegrationservices

For the new project I am working on, I am trying to export data from multiple SQL tables with different columns and data into multiple sheets in the same Excel workbook. 对于我正在从事的新项目,我试图将具有不同列和数据的多个SQL表中的数据导出到同一Excel工作簿中的多个工作表中。 Since the data is different for each table, the Dataflow Task in the example above doesn't appear to be dynamic to allow for the changes to columns and data conversions. 由于每个表的数据都不同,因此上例中的“数据流任务”似乎不是动态的,因此无法更改列和数据转换。

I know that this is possible using the SQL Server Import and Export Wizard but I am looking at over 200 tables. 我知道可以使用SQL Server导入和导出向导来实现,但我正在查看200多个表。 Instead, I have passed the desired table-names to an object variable in SSIS using the SELECT TABLE_NAME FROM information_schema.tables query. 相反,我已使用SELECT TABLE_NAME FROM information_schema.tables查询将所需的表名传递给SSIS中的对象变量。 Perhaps there is a script that could deal with this. 也许有一个脚本可以解决这个问题。 I am new to SSIS and although haven't used VB for several years, I am willing to use it or any other method to achieve the result. 我是SSIS的新手,尽管已经有好几年没有使用VB了,但我还是愿意使用它或任何其他方法来达到目的。

Am I missing something? 我想念什么吗? Is this procedure possible in SSIS? 在SSIS中可以执行此过程吗?

It will be quite hard to do this in simple way. 用简单的方法很难做到这一点。 If you have different columns in tables you would like to have multiple different data flow tasks. 如果表中的列不同,则您希望执行多个不同的数据流任务。 You can create the packages "dynamicly" using the BIML using for example C# - read more here: https://www.mssqltips.com/sqlservertip/3124/generate-multiple-ssis-packages-using-biml-and-metadata/ Please think about using the import/export wizard from Management Studio (later you can save this into the SSIS package and reuse). 您可以使用BIML(例如C#)使用BIML“动态”创建包-在此处阅读更多信息: https ://www.mssqltips.com/sqlservertip/3124/generate-multiple-ssis-packages-using-biml-and-metadata/请考虑使用Management Studio中的导入/导出向导(以后可以将其保存到SSIS包中并重复使用)。

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

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