Inserting Data into SQL Server from variables via SSIS

后端 未结 1 1636
死守一世寂寞
死守一世寂寞 2020-12-22 10:10

I have consumed simple web service for addition of two numbers and I am getting the result in xml format that I have stored in variable supposed named as my_data, now I have

1条回答
  •  囚心锁ツ
    2020-12-22 10:57

    I suggest you build this SQL statement in another variable, as explained here:

    http://consultingblogs.emc.com/jamiethomson/archive/2005/12/09/2480.aspx

    Then use that variable in your execute SQL statement

    Normally you would try and parameterise the query but in this case (as in many others) it won't work.

    Here are some more detailed instructions:

    A. Generate the dynamic SQL

    1. Create a new SSIS variable of type string
    2. In properties, set it's 'Evaluate as Expression' to TRUE
    3. In properties, click on 'Expression' and build an expression as follows:

      "INSERT INTO Data_Result(Result) VALUES ('"+@[USER::my_data]+"')"

    4. Press Evaluate and verify that the output is valid SQL (you may even wish to paste it into SSMS and test)

    B. Get an Execute SQL task to run your SQL:

    1. Drop a execute SQL task on your page. Set it's connection
    2. With the execute SQL task highlighted, go to properties and click expressions
    3. Pick the property 'SQLStatementSource'. In the expression pick your variable that you built in step A and press evaluate.
    4. Press OK on everything

    Now whatever change occurs in my_data will automatically be applied to your execute SQL task

    Try that for starters and get back to me.

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