how to pass parameters to an ado.net source in ssis?

后端 未结 2 913
一整个雨季
一整个雨季 2021-01-01 02:34

This is the original query, which works fine using ado.net source and using the .net providers\\odbc data provider specified inside the source.

         


        
相关标签:
2条回答
  • 2021-01-01 02:48

    You can use the following steps:

    1. Use your working query into the ADO.NET source.[You could not map the parameters for the ADO.NET source]
    2. Select your Dataflow and click Properties.
    3. In the properties pane, look for the property named "Expressions". Expand it and click the "..." icon to open the Property Expressions Editor (screenshot below). Select the property SqlCommand for your Data Source and using the Expression builder prepare your query using SSIS variables (datetime variable in your case).

    ADO.NET Query preparation

    Try this in your expression builder -- note that your variable must be a string, if it's not, you use (DT_WSTR,30) to cast it. Since you're using dates, your SQL will need to handle a string-formatted date, i.e. use to_date() in Oracle.

     "SELECT a.FA_CLNT_ID, a.FA_ACCT_NM, a.ACCT_E_DT, a.POL_PER_CURR_DT, a.POL_PER_NEXT_DT, a.FA_ACCT_NUM, a.GRP_SALES_OFFC_CD, a.ACCT_C_DT   
    FROM  gyv2M.DDM_ACCT_STRUC a   
    INNER JOIN  
    (SELECT max(DDM_ACCT_STRUC_TP) as   DDM_ACCT_STRUC_TP, FA_CLNT_ID 
     FROM gyv2M.DDM_ACCT_STRUC 
    WHERE FA_DM_ROW_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"'  AND DM_ROW_E_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"' 
     GROUP BY  FA_CLNT_ID) b 
     ON a.DDM_ACCT_STRUC_TP = b.DDM_ACCT_STRUC_TP AND a.FA_CLNT_ID = b.FA_CLNT_ID AND FA_DM_ROW_DT <= '" +(DT_WSTR,30)@[User::RepDate] +"' AND a.DM_ROW_E_DT <='"+(DT_WSTR,30)@[User::RepDate]+"'"
    

    Hope this helps!

    0 讨论(0)
  • 2021-01-01 03:03

    Try this in your expression builder,

     "SELECT a.FA_CLNT_ID, a.FA_ACCT_NM, a.ACCT_E_DT, a.POL_PER_CURR_DT, a.POL_PER_NEXT_DT, a.FA_ACCT_NUM, a.GRP_SALES_OFFC_CD, a.ACCT_C_DT   
    FROM  gyv2M.DDM_ACCT_STRUC a   
    INNER JOIN  
    (SELECT max(DDM_ACCT_STRUC_TP) as   DDM_ACCT_STRUC_TP, FA_CLNT_ID 
     FROM gyv2M.DDM_ACCT_STRUC 
    WHERE FA_DM_ROW_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"'  AND DM_ROW_E_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"' 
     GROUP BY  FA_CLNT_ID) b 
     ON a.DDM_ACCT_STRUC_TP = b.DDM_ACCT_STRUC_TP AND a.FA_CLNT_ID = b.FA_CLNT_ID AND FA_DM_ROW_DT <= '" +(DT_WSTR,30)@[User::RepDate] +"' AND a.DM_ROW_E_DT <='"+(DT_WSTR,30)@[User::RepDate]+"'"
    

    Hope this works!

    0 讨论(0)
提交回复
热议问题