zoukankan      html  css  js  c++  java
  • [转]Mapping Stored Procedure Parameters in SSIS OLE DB Source Editor

    本文转自:http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-ole-db-source-editor.aspx

    I was working on a SSIS Data Flow Task by passing Package Variables into a Stored Procedure. I will be using [AdventureWorks] sample database included with the SQL Server installation. Below is the screenshot of bits and pieces of my SSIS Package configuration.

    As you can see, I have defined 2 Package Variables and using the [AdventureWorks] database connection and a Flat File Connection Manager to dump out the [uspGetWhereUsedProductID] Stored Procedure's output.

    My SSIS Package Configuration Overview

    This is the SQL command text I am using in the OLE DB Source Editor dialog window.

    EXEC [dbo].[uspGetWhereUsedProductID] ?, ?

    Here is the screenshot of the Parameter Mapping.

    Incorrect Stored Procedure Parameter Mapping

    As you can see, Parameter0 and Parameter1 were used to match the Stored Procedure's parameters' ordinal positions. When I execute the Data Flow Task, I get the following error message.

    The SQL command requires a parameter named "@ParameterName", which is not found in the parameter mapping. component "OLE DB Source" (1) failed the pre-execute phase and returned error code 0xC0207014.

    It was obvious that I am not mapping the Stored Procedure's parameters with the SSIS Package Variables correctly. I looked up OLE DB Source in the MSDN Library Documentation. The Specifying Parameters by Using Names section used AdventureWorks database's [uspGetWhereUsedProductID] stored procedure as an example and passing in @StartProductID and @CheckDate parameters.

    The following SQL statement runs the uspGetWhereUsedProductID stored procedure, available in the AdventureWorks database.
    EXEC uspGetWhereUsedProductID ?, ?
    The stored procedure expects the variables, @StartProductID and @CheckDate, to provide parameter values. The order in which the parameters appear in the Mappings list is irrelevant. The only requirement is that the parameter names match the variable names in the stored procedure, including the @ sign.

    That is *exactly* what I am doing and I am getting the error. So I am pretty sure the MSDN Documentation is not clear enough (or maybe even incorrect).
    Additionally, I looked up How to: Map Query Parameters to Variables in a Data Flow Component listed under the Configuring the OLE DB Source section. Again, it doesn't give any more information. By this point, I was getting pretty frustrated.
    I browsed the MSDN Forums and discovered that many other developers are having the SAME problem. I carefully re-read the OLE DB Source documentation in case I missed something and finally noticed this line.

    The only requirement is that the parameter names match the variable names in the stored procedure, including the @ sign.

    I added/replaced the following with the actual Stored Procedure's Parameter names.

    • The Question Marks (?) in the SQL command text
    • Parameter0 and Parameter1 in the Set Query Parameters dialog window

    Correct Way to Map Stored Procedures Parameters in OLE DB Source

    I was very happy to discover that my SSIS Package runs successfully after the changes.
    I really wished the MSDN Documentation team gave more details on OLE DB Source Parameter Mapping. It would have saved me the headache of looking for a solution and feeling like pulling out my hair.
    Happy Programming, Soe

  • 相关阅读:
    centos7查看yum安装的软件及路径
    CentOS7图形界面与命令行界面切换(转载)
    vmware安装centos7
    如何在IE11中设置兼容模式?设置的具体方法
    docker批量删除容器、镜像
    在Linux Centos 7.2 上安装指定版本Docker 17.03
    如何避免命令 rm -rf 的悲剧
    python django整理(五)配置favicon.ico,解决警告Not Found: /favicon.ico(转载)
    Ubuntu终端命令行缩短显示路径
    virtualenv 虚拟环境依赖安装
  • 原文地址:https://www.cnblogs.com/freeliver54/p/3578017.html
Copyright © 2011-2022 走看看