简体   繁体   English

执行SQL任务(SSIS),然后将结果集插入其他服务器上的表中

[英]Execute SQL task (SSIS) and then insert the result set into a table on a different server

This is more of a generic question : 这更多是一个通用的问题:

I have file1.sql, file2.sql , file3.sql in a folder. 我在文件夹中有file1.sql,file2.sql,file3.sql。 I can run a foreach container to loop through the files and execute it but I need the result set to go to respective tables sitting on a different server 我可以运行一个foreach容器来遍历文件并执行它,但我需要将结果集转到位于不同服务器上的各个表

file1 result set --> Server2.TableA file2 result set --> Server2.TableB .. etc file1结果集-> Server2.TableA file2结果集-> Server2.TableB ..等

How can this be achieved through SSIS techniques ? 如何通过SSIS技术实现这一目标?

您可以使用foreach循环中的脚本任务来执行此操作,该脚本任务将分析结果集并将其插入到适当的目标表中。

You could also put all the records into a staging table on one server with additional columns for that server they will go to and a isprocesssed bit field. 您还可以将所有记录放入一台服务器上的登台表中,并将它们添加到该服务器的其他列以及一个isprocessed位字段中。

At this point you could do any clean up required of the data. 此时,您可以对数据进行任何清理。

Then create a separate dataflow for each server to grab the unprocessed records for that server. 然后为每个服务器创建一个单独的数据流,以获取该服务器的未处理记录。 After they are sent, then mark the records as processed. 发送它们后,然后将记录标记为已处理。

This will work if you only have a few servers. 如果您只有几个服务器,这将起作用。 If there are many possibilities or you expect the number will continue to change, I would go with @TabAlleman's suggestion. 如果有很多可能性,或者您希望数字继续变化,我将接受@TabAlleman的建议。

thestralFeather, thestralFeather,

If you are new to SSIS, refer to msdn's tutorial on looping utilizing SSIS here . 如果您不熟悉SSIS,请在此处参考msdn关于使用SSIS进行循环的教程。 If you look at this page within the tutorial, you will see in the dataflow the output destination. 如果您在教程中查看页面,您将在数据流中看到输出目标。 @Tab Allerman and @HLGEM have provided good advice. @Tab Allerman和@HLGEM提供了很好的建议。 When you look at the pages I've referred you to, just thing in terms of 2 separate loops dropping data to a single location that you can manage in a target dataflow. 当您查看我所引用的页面时,仅用2个单独的循环就可以将数据拖放到可以在目标数据流中管理的单个位置。

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

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