本文转自:http://www.programmersedge.com/post/2013/03/05/ssis-execute-sql-task-mapping-parameters-and-result-sets.aspx#.U18_6PmSxBk

A very common scenario in an ETL process is one in which you need to call out to some configuration tables to figure out some values that it needs to use somewhere downstream in the process. Quite often you also want to pass in some parameters as well. So in this article I will be addressing both of those scenarios. To start, you will just need to drop an Execute SQL Task item onto the Control Flow of an SSIS package and set up the initial configuration so that it is basically given a connection string

Now we want to enter in our SQL statement that will contain the parameters. In this case we are using a SQL Server connection and I will be calling a stored procedure. So I will provide ?s for each of the parameters involved. So my statement look like this…

exec Staging.usp_GetTicketQueries ?,?,?

I could also be more verbose if I wanted to

exec Staging.usp_GetTicketQueries  @StartDate=?,@EndDate=?,@SomeOtherValue=?

but it isn’t entirely necessary. Now that I have the statement ready I just need to click on the Parameter Mapping menu item on the left hand side and map my parameters.

Notice that there isn’t anything really tricky here. I line out the variables that will be used with the appropriate type and size. The only part that trips a lot of people up is the fourth one which is the Parameter Name. When you initially add an additional parameter to map this column will have a text name in it. Instead what I have done is to change these so that instead it has the 0 based index of the parameters in my statement. Once you have them mapped to the proper index value then everything should be golden.

Now we want to grab that result set that is being sent from the stored proc and map its values to some different variables. So we need to go back to the General settings screen and in the “Result Set” section change the value of the ResultSet property to something other than None in order to be able to make changes to the ResultSet screen later. In this case, I am just returning a single row. So I merely change the value to Single row and I am ready to map the result set.

Now switch to the Result Set screen via the menu on the left. Here what you will want to do is to map the actual column names of the result set to the variables that you want them to be placed into. Pretty simple. In the end, you will have something that looks like this.

Now you can click OK as you are finished with the process. This is actually a fairly handy thing to know in order to make your ETL processes a little more dynamic.

Cheers!

AJ

[转]SSIS Execute SQL Task : Mapping Parameters And Result Sets的更多相关文章

  1. SSIS Execute SQL Task 用法

    Execute Sql Task组件是一个非常有用的Control Flow Task,可以直接执行SQL语句,例如,可以执行数据更新命令(update,delete,insert),也可以执行sel ...

  2. [转]Working with Parameters and Return Codes in the Execute SQL Task

    本文转自:http://msdn.microsoft.com/zh-cn/magazine/cc280502(en-us,SQL.100).aspx SQL statements and stored ...

  3. 微软BI 之SSIS 系列 - Execute SQL Task 中的 Single Row 与 Full Result Set 的处理技巧

    开篇介绍 Execute SQL Task 这个控件在微软BI ETL 项目中使用的频率还是非常高的,也是大部分入门 SSIS 初学者最早接触到的几个控制流控件. 我们通常使用 Execute SQL ...

  4. Execute SQL Task 参数和变量的映射

    Execute SQL Task能够执行带参数的SQL查询语句或存储过程(SP),通过SSIS的变量(Variable)对参数赋值.对于不同的Connection Manager,在Task中需要使用 ...

  5. Execute Sql Task 的Result DataSet如何返回

    Execute Sql Task的Result DataSet 主要有以下四种,当Execute Sql Task返回结果之后,需要使用SSIS Variable 来接收数据. 例子中使用的数据表代码 ...

  6. Execute SQL Task 如何返回结果数据集

    Execute Sql Task的Result DataSet 主要有以下四种,当Execute Sql Task返回结果之后,需要使用SSIS Variable 来接收数据. 例子中使用的数据表代码 ...

  7. SSIS中Sql Task 获取系统变量

    原文:SSIS中Sql Task 获取系统变量 执行 SQL 任务使用不同的连接类型时,SQL 命令的语法使用不同的参数标记.例如,ADO.NET 连接管理器类型要求 SQL 命令使用格式为 @var ...

  8. ssis的script task作业失败(调用外部dll)

    原文 ssis的script task作业失败 我的ssis作业包里用了一个script task,会查询一个http的页面接口,获取json数据后解析然后做后续处理,其中解析json引用了本地目录下 ...

  9. Execute Process Task

    Execute Process Task 用于在Control Flow中执行应用程序,常用于对加密的数据进行解压. 1,RequireFullFileName 属性:是否需要完整的文件路径,如果在F ...

随机推荐

  1. NOIP 2013 day2

    tags: 模拟 贪心 搜索 动态规划 categories: 信息学竞赛 总结 积木大赛 花匠 华容道 积木大赛 Solution 发现如果一段先单调上升然后在单调下降, 那么这一块的代价是最高的减 ...

  2. linux命令(22):mkdir命令

    实例1:创建一个空目录 mkdir  test 实例2:递归创建多个目录 mkdir  -p /home/test 实例3:创建权限为777的目录 mkdir -m 777 test 实例4:创建新目 ...

  3. hdu 1269 迷宫城堡(Targin算法)

    ---恢复内容开始--- 迷宫城堡 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  4. 183. Customers Who Never Order

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  5. CSS让文字在元素内绝对居中!!!【ie和谷歌】

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 设置loadrunner中每个mdrv.exe进程中包含的vuser个数

    设置loadrunner中每个mdrv.exe进程中包含的vuser个数 在loadrunner中,默认的是每50个vuser会使用一个mdrv.exe进程,但是有些时候vuser中的使用的线程太多就 ...

  7. HDU 4348.To the moon SPOJ - TTM To the moon -可持久化线段树(带修改在线区间更新(增减)、区间求和、查询历史版本、回退到历史版本、延时标记不下放(空间优化))

    To the moon Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  8. python中浅拷贝和深度拷贝的区别

    在很多面试题中都会问到浅拷贝跟深度拷贝的区别,前几天一个朋友也问到了我浅拷贝跟深度拷贝到底有什么区别,这里就简单举栗子讲一下两者的区别. 浅拷贝(copy()):拷贝父对象,不会拷贝对象的内部的子对象 ...

  9. ZOJ 3949 Edge to the Root(想法)(倍增)

    Edge to the Root Time Limit: 1 Second      Memory Limit: 131072 KB Given a tree with n vertices, we ...

  10. B/S架构和C/S架构

    一.B/S架构 B/S结构(Browser/Server,浏览器/服务器模式),是WEB兴起后的一种网络结构模式,WEB浏览器是客户端最主要的应用软件.这种模式统一了客户端,将系统功能实现的核心部分集 ...