passing a variable to an execute sql task sql script

  • hello,  I have written the below sql script to update a table however I am having an issue passing a package variable to the script.
    can anyone tell me if I am on the right lines here please?
    Is it allowed to set a scalar variable to a ?

    Declare @Table_Name varchar(100),
    @Table_Name_Short varchar(100)

    set @Table_Name = ?
    set @Table_Name_Short = rtrim(substring(@Table_Name,1,charindex('-',@Table_Name,1)-1))
    declare @sql varchar(5000)

    set @sql =

    'UPDATE ' +
    @Table_Name_Short +

    ' set ' + @Table_Name_Short  + '.' + 'P360_value1 = tpmapUPDATE_1.P360_value1,'
      + @Table_Name_Short  + '.' + 'UpdateDate = CONVERT(date,getdate())

    from
    tpmapUPDATE_1
    left outer join ' +
     @Table_Name_Short +' on ' +
      @Table_Name_Short +'.AGM_System = tpmapUPDATE_1.AGM_System and
      rtrim(' + @table_name_short + '.TP_Value1) = rtrim(tpmapUPDATE_1.TP_Value1  )

    where
    RTRIM(tpmapUPDATE_1.table_name) = '  + '''' + @Table_Name_Short + '''' +' and
    rtrim(' +  @Table_Name_Short + '.' +'AGM_System) =rtrim(tpmapUPDATE_1.AGM_System) and
    rtrim('  + @Table_Name_Short + '.' + 'tp_value1) = rtrim(tpmapUPDATE_1.tp_value1)and
    rtrim('  + @Table_Name_Short +  '.' + 'P360_value1) <> rtrim(tpmapUPDATE_1.P360_value1)


    '

    exec (@sql)

    my parameter mapping is as follows:

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeIAAABICAYAAAAqGfafAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAxcSURBVHhe7Z2xzhy3FYXXgQu/RAq5s5EU9iNYnQ2k0SMF7lIZeYZ0SYAAcSf5DeRCgdRFhV9ChQGbhzt3/ztHl0MOl7uzu3M+QD46vPeSM5yZ5fDfH9Ynb9+8/u0ghBBCiE34w6RCCCGE2AAtxEIIIcSGaCEWQgghNkQLsRBCCLEhWoiFEEKIDdFCLIQQQmyIFmIhhBBiQ7QQCyGE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zn2jKt/id+PSoV/PtJze8s/U71+g5Rf3p/i74U3+ubjY+mLRnvI/6G+Qxb4v5HGfP+TvxLfdb6BOr8h/M53kjhn1HbA+N/07I3oTMQ/NDF+Rbe4b7Tyx6V1c6nlM8Ac/Hk3F1HOfxTh6wT8Dj/P18ZJCXCOvBVGfjox7+lD/pI/vad8SYF5AV7YlZvvlEdD/y/ALk++u1NP6t+vSot+UnFj0UOLW4PR/sZ/Pp66e8nA8m7R1v1t8gj3lbiu/9eSz55vvNeXveMJ8t+Y/o87wRq/71JTwUWNmPnWKFT53Kyw/2z/744fDul/P7w0OPnVdv/b35L9K8vU/zNqq/vfhR99vevO63Po/7Tf/6UqfmXzgIsB1zaz/SumLnMWJeR/VzL6r/01Gfat76VPPWp0P+z1rHlX3sz8zvwfN3WuZH9S//5Fu+I27xe7s+6b17aH978Zi3kf3txet+6/N53gjtiKU3p3vbyY5S7VD6VPPWp5q3Ph2yIx75ZiAvH/njLwa258sfvXZ2fV47uz6v+63Pa0csvQvVjrhPtUPpU81bn2re+jTaEa/6rWnsVLAzlkovren98fjGLZVKpQ+kvAiD5oX45auXU4sQQgghRtH8HbEQQgghxqOFWAghhNgQLcRCCCHEhmghFkIIITZEC7EQQgixIVqIhRBCiA3RQiyEEEJsiBZiIYQQYkO0EAshhBAbooVYCCGE2IzD4XfILP7oGPhILQAAAABJRU5ErkJggg==

    my variables are as follows:

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAa8AAAB/CAYAAABYIk2aAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAABiNSURBVHhe7Z0/bBzHkoeLwjtgDSigMhJwost4uBdYmZWZylbZGXDCyDCsxIAB24IA2oIDnR4DWnAi05GZ2OBl5EVyYEF0YENwRAmQIWVPCYFlxgVOgDZ4AK+rd4sutrrnz3Kmd3r79wHNmq7ume2truma2h3OLpwYXvz5hHpENDKF5b///Qr989nBqWT9f5jt52Zb2gXdL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cfHtDqhglcRsV1Dm5XPr1Hqz8d2372bsPJLyq3+YSNadFXobrME7jy7B6zXFC1n+cQwOD/YXIK7OPMyxS+CcPeRWiql4wFWC5OJPOWCXJcOHD1TOAaTZl5tY2+CtVlnqhr9abf/7zZswlmuaDOq5+HyGmBrktOgd1mXvKsQg5g9vsvs23vKmT9pG7lJOMasmQ6mHnlAKzePbCgxgP+HyYnP1yg93ZObAZlghMHMhuQatTxVPn44Kna3QNPlY8H/D9MTn6IX1JOECyU3QMLajzg/2Fy8sOF588OTjjV5FQcEhISEjJdmdMFFDIvAAAAyXFhIgEAAIBkQPACAACQHAheAAAAkgPBCwAAQHIgeAEAAEgOBC8AAADJgeAFAAAgORC8AAAAJAeCFwAAgORA8AIAAJAcCF4AAACSA8ELAABAciB4AQAASA4ELwAAAMmB4AUAACA5ELwAAAAkB4IXAACA5EDwAgAAkBwIXgAAAJIDwQsAAEByIHgBAABIDgQvAAAAyYHgBQAAIDkQvAAAACQHghcAAIDkQPACAACQHAheAAAAkgPBCwAAQHIgeAEAAEgOBC8AAADJgeAFAAAgORC8AAAAJAeCFwAAgORA8AIAAJAYRP8PSgsZFQhLSrUAAAAASUVORK5CYII=

    variable table_name is the filename of a text file in a for each loop container.

    hence it being blank here.

    Many thanks,

    Dave

  • I wouldn't do it like this. Use an expression within SSIS to create your SQL and store than value in a variable; then, instead of using the option Direct Input for SQLSourceType, use Variable, then select your variable for the SourceVariable option.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • I think it depends if your Execute SQL task is using an OLEDB connection or ADO.NET connection to the database, they work differently.
    If using ADO.NET connection then you use an undeclared variable in your script such as:
    SET @Table_Name = @Parm_Table_Name
    then you use the Parameter Mapping page of the Edit dialog of the SQL Task and map your package variable User::blahblah to the ParameterName @Parm_Table_Name.

    If using an OLEDB connection, then you use the ? notation like you did above.

    Of course you could use the dynamic SQL method Thom describes if you are sure you have clean values for your parameter and are avoiding SQL Injection.

  • Thom's method is the way I would go.

    I'd probably create a package parameter to contain the 'template' SQL, so

    SQLTemplate = '
    Declare @Table_Name varchar(100),
    @Table_Name_Short varchar(100)

    set @Table_Name = the_table_name
    set @Table_Name_Short = rtrim(substring(@Table_Name,1,charindex(''-'',@Table_Name,1)-1))
    declare @sql varchar(5000) ...
    '
    And then define a package variable SQLVar with an expression like

    SQLVar = Replace($Package::SQLTemplate,"the_table_name", the_real_table_name)

    and then use SQLVar as the source for the Exec SQL task.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Hi all, thanks for the advice.
    I have gone with Thoms suggestion and it's working very nicely.
    I am having an additional issue with importing the data due to differing datatypes in a column but I will post it in a separate thread.

    Have a good evening all
    ,
    Best Wishes
    Dave

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply