0

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 to insert that result in my sql table named as Data_result by writing query in oledb source editor, but unable to insert data using variable.I just want to store all the result calculated by my web service in sql table.

Since I am newbie to SSIS, any help is greatly appreciated

When I am trying to insert the data by the following query command:

"INSERT INTO Data_Result(Result) SELECT '"+@USER::my_data+"'"

It's giving error:

Error at Data Flow Task [OLE DB Source [55]]: No Column Transformation was return by SQL Command

--------Updated explanation of errors based on the solution given

Error for executing query If I place the expression without the "" quotes then I get following error enter image description here

If I place the query in double quotes then following error is shown enter image description here

And if I remove User from User::Data Variable and place the query in double quotes then I get following screen enter image description here although the expression evaluates but after proceeding further on this evaluated expression when I am trying to search for the variable in expression column of Execute sql Task, then I am unable to locate the newly created variable, as shown below enter image description here

------------Updated question according to other query----------

Here is the picture of my whole work flow

enter image description here

This is what I have did inside the for each loop container under collection tab

enter image description here

And this below setting I have done between Variable mapping tab,

enter image description here

And in below screen shot, I am using Execute SQL Task to enter my data obtained from web service task into database using an insert query, but unable to fire proper insert query,

enter image description here

And below is my XML file,

<?xml version="1.0" encoding="utf-16"?>

Reshma

1988-09-23T00:00:00 ,

This name and birthdate I received from web service I want to insert that into database table

--------------Updated question for foreach loop container--------

Below is the foreach loop container I am using,

enter image description here

But still I am not getting node value into variable and also I am suppose to make use of object type variable or it can work with string type of variable.

4
  • 1
    Could you post printscreens of your control and data flows? I think you may be using sqltask or oledb command wrong way. Commented Sep 9, 2013 at 11:16
  • @frikozoid.. Can you please follow the link [stackoverflow.com/questions/18720095/… to check my Execute Sql Task setting, here I have done through inserting stored procedure and also the another trial I have explained on the same page using variable but still facing an issue in query..I have explained both the issue in screen shots. Commented Sep 11, 2013 at 5:56
  • What happens when you drag User::Data from the top left window into your expression and evaluate - does it work? what if you put "test" + in front of it - does it work? Commented Sep 11, 2013 at 6:48
  • I've also changed my post below and altered the format - try it. I've added square brackets to the expression Commented Sep 11, 2013 at 6:50

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

15 Comments

..I am not able to build proper insert command, I have written query as follows "INSERT INTO Data_Result (Result) values ('@USER::Data')", then it's giving me error on evaluating expression that attempt to parse the expression failed.The expression might contains an invalid token, an incomplete token, or an invalid element. It might not be well formed or might be missing part of required element such as parentheses whereas USER::Data is my User variable, even if i rewrite the values by any Number, it gives the same error.
I have added more detail to my reponse. Note you need to use an execute SQL Task, not a data flow task.
..I have created the new variable as explained by you but still unable to resolve the issue as explained in the above question asked by me, I have done required edition in it with necessary screen shots.
..it worked but unable to store data into database in proper format, please follow the below link, [stackoverflow.com/questions/18738310/…
@ElectricLlama.."INSERT INTO Data_Result(Result) VALUES ('"+@[USER::my_data]+"')"..this query insert only one value but what if I want to take no of elements in my_data user variable and wants to insert the array of values in database then what should I do?..I am also making use of for each loop container but unable to store data into database looping through variable , also my web service is now giving more than one data into xml file.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.