简体   繁体   English

返回执行SQL任务的单行单值结果集,作为对SSIS中另一个执行SQL任务的输入

[英]Return single row single value result set of Execute SQL task as an input to another execute SQL task in SSIS

I need to pass the single value result of an execute SQL task as the input to another. 我需要将执行SQL任务的单值结果作为输入传递给另一个。 I need to have to separate tasks since I need 2 different connections. 我需要分开两个任务,因为我需要2个不同的连接。 (both SQL Server, but different environments) (都是SQL Server,但是环境不同)

Ok simple. 好吧,简单。 First create a variable for the value you want to pass. 首先为您要传递的值创建一个变量。

Then in your execute sql task, write the query that brings up that value. 然后在执行sql任务中,编写查询该值的查询。 Make sure to set the result set to single row. 确保将结果集设置为单行。

Then go to the variables tab and add your new variable in there. 然后转到变量标签,并在其中添加新变量。

Once that's done, go to your next task, and in the parameters section add your variable there. 完成后,转到下一个任务,然后在“参数”部分中将变量添加到那里。 I'm assuming both tasks are sql tasks. 我假设这两个任务都是sql任务。

Then in the query for the second task use a ? 然后在第二个任务的查询中使用? Symbol to represent the variable. 代表变量的符号。

Let me know if that makes sense. 让我知道这是否有意义。 I can post screenshots tonight. 我可以今晚发布屏幕截图。

Your question can be divided into 2 parts: 您的问题可以分为2部分:

  1. Passing the Execute SQL Task result into a variable : You can refer to the following articles to learn more about how to use ResultSets to store an Execute SQL Task result into SSIS variables: 将Execute SQL Task结果传递给变量 :您可以参考以下文章,以了解有关如何使用ResultSets将Execute SQL Task结果存储到SSIS变量中的更多信息:

  2. Passing the variable as parameter for another Execute SQL Task : You can refer to the following articles to learn more about passing parameters to Execute SQL Task: 将变量作为参数传递给另一个Execute SQL Task :您可以参考以下文章,以了解有关将参数传递给Execute SQL Task的更多信息:

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

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