• [转]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

  • 相关阅读:
    Android--MediaPlayer高级
    Android--SoundPool
    Android--MP3播放器MediaPlayer
    Android--加载大分辨率图片到内存
    Android--Task和BackStack高级
    Android--Activity的启动模式
    Android--操作图片Exif信息
    JDK5.0特性,使用ProcessBuilder执行本地命令
    MySQL 读写分离 使用驱动com.mysql.jdbc.ReplicationDriver
    kafka delete topic
  • 原文地址:https://www.cnblogs.com/freeliver54/p/3578017.html
Copyright © 2020-2023  润新知