I want to insert the below XML Data retrieved from web service task into my Database,
<?xml version="1.0" encoding="utf-16"?>
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name xmlns="http://Iycon.com/WebService">Rahul</Name>
<BirthDate xmlns="http://Iycon.com/WebService">1988-09-23T00:00:00</BirthDate>
</Data>,
I am making use of foreach loop container to loop through different nodes but unable to get the result, this data I am inserting into database via Execute SQL Task, I have tried lot but unable to find solution,Thank You,
You can try the following to get the data into SQL Server.
Add Webservice Task
This retrieves the complete node set from the web service.
Update a variable(object) with the web service response data.
Add Data Flow Control
Add XML Source Control
Use XML from variable and generate the XSD
Add OLE Destination Control
Map your columns to match the XML nodes exposed from the XML Source.
Related
I'm relatively new to SQL Server, so please bear with me!
I have a XML file with multiple elements that I am trying to load into a database table, see below:
<ReportStatus>
<Change>
<Signatory>XXX</Signatory>
<Status>XXX</Status>
<StatusTime>XXX</StatusTime>
</Change>
<Message>
<CreationTime>XXX</CreationTime>
<ID>XXX</ID>
<Version>0.0.1</Version>
</Message>
<Request>
<References>
<Reference>
<RefId>Reference</RefId>
<RefValue>XXX</RefValue>
</Reference>
</References>
<RequestNr>XXX</RequestNr>
<Service>
<Name>XXX</Name>
<Type>XXX</Type>
</Service>
</Request>
The flow will only let me load one element at one time, I have tried loading the data into the table as such:
However, this loads the data into the table in 2 separate records:
Is there a way to consolidate these 2 elements before placing them into the table so the entire record is loaded as a single record?
Thanks in advance!
EDIT
Here's the table with the matching fields:
I am new to SSIS, I am trying to load data from XML file into SQL server table. I have created the project and can transform and load data into table, but with one issue, below is sample of XML data
<EventLocationInfo>
<Facility>NY 31</Facility>
<Direction>eastbound</Direction>
<City>Cicero</City>
<County>Onondaga</County>
<State>NY</State>
<LocationDetails>
<LocationItem>
<Intersections>
<PrimaryLoc>I-81</PrimaryLoc>
<Article>area of</Article>
</Intersections>
</LocationItem>
<LocationItem>
<PointCoordinates Datum="NAD83">
<Lat>43.1755981445313</Lat>
<Lon>-76.1159973144531</Lon>
</PointCoordinates>
</LocationItem>
<LocationItem>
<AssociatedCities>
<PrimaryCity>Cicero</PrimaryCity>
<Article>area of</Article>
</AssociatedCities>
</LocationItem>
</LocationDetails>
</EventLocationInfo>
The result I am getting is like this
Is it possible to generate only one row instead of getting three different rows, if possible what Data Flow Transformation tool i can use to get this result.
Please help, thanks in advance.
Brijesh
I have an XML feed from a wholesaler that is updated periodically to show the stock quantities of the items they wholesale. I need some help in collecting that XML file data twice a day and importing it into the SQL table on my website. Here is an example of the XML file:
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE stockreport SYSTEM
'http://www.wholesalewebsite/feeds/status.dtd'>
<stockreport>
<timestamp>14/07/2014 18:55:26</timestamp>
<version>2.0</version>
<products>
<product type="main">
<code>M0507</code>
<name>Example Product</name>
<stock>4</stock>
<status>In Stock</status>
</product>
</products>
</stockreport>
I need to use this feed to update the quantities of the items in my store. My SQL table is called prods_stock and in the table the code (M0507) is called customid and stock is called quantity, so I need to alter the XML fields to match my existing table fields and then update the quantities using the customid(code) as an anchor point. I can ignore name and status.
How would I go about doing this?
Thanks in advance
Thanks for the suggestions, as I am not very good with coding etc... I have decided to just manually insert an sql query daily to update the database. An example of the code I will use is:
UPDATE products_stock SET customid = 'n12',quantity = 10 WHERE 1=1 AND customid= 'n12';
UPDATE products_stock SET customid = 'n50',quantity = 10 WHERE 1=1 AND customid= 'n50';
I will be using a csv feed file from the wholesaler and getting the info from there. Is there an easier/quicker way to drag the info from the csv file and update the table, rather than manually type the code for each line?
Thanks
You may have a look at XSLT. That allows you to parse any XML file and transform it's contents into any form you like. Using that you could transform the XML into SQL queries and run them agains the database.
You could then write a small shell script that loads the XML file, runs the XST-rules and hands the result on to the database.
You cannot archive that without any programming knowledge, but XSLT ist quite simple for such simple use cases. First I would work through a basic XSLT tutorial to become familar with the basics and then try it out with our problem.
Happy learning.. :)
Hello and thank you in advance,
Is it possible to use REST API calls to retrieve data either in XML or JSON format from a script in SQL and then insert this data into records of a created table?
Let me be more clear with my question: The API is using REST "http://api.monitis.com/api/api.html"
Say for instance the output is as such:
<result>
<location id="4" name="UK1">
<row>
<cell>00:00</cell>
<cell>152</cell>
<cell>ok</cell>
</row>
So essentially I need to call through http REST API using the URL with parameters:
http://api.monitis.com/api?apikey=[apikey]&output=xml&version=2&action=testresult&testId=288571&day=03&month=10&year=2013&locationIds=1&timezone=-240
and then after retrieving the data I would need to be able to insert the data into a table after parsing for the data for 4 columns [location],[Time],[Response],[Status]
The process flow would be:
1.) Call the API with the desired parameters
2.) Serialize the XML
3.) Insert data into created table
I think its a really bad idea, but it should be possible.
Try this article for some tips to get you started:
http://www.databasejournal.com/features/mssql/article.php/3821271/Calling-a-Web-Service-from-within-SQL-Server.htm
but I agree with #marc_s, this would better be done in a different tier.
My current client stores all of their configuration information for the enterprise applications in a single table that holds XML. They then use a custom built front end to maintain the configuration values.
I'm writing a fairly straight-forward import process for them using SSIS. I need to make the connection strings and some other information configurable and they want me to use their table. It seems like SSIS expects a file though. Is there any way that I can point SSIS to retrieve its configuration values from an XML stream instead of a path to a file?
The configuration table that they use does not match the structure of a standard SSIS configuration table that you would get using SQL Server as a configuration source with the standard wizard.
Thanks for any advice!
You can retrieve values from the table, put it in variables, and using a script, transfer the varaibale values into the SSIS parameters.
Having the XML formatted just like the SSIS XML file is a huge bonus, though.
Is there a away to put a trigger on thier table to update the SQL Server config table or create a new XML document anytime an SSIS configuration is inserted or updated? Then you could use what you need and they could do what they need and all would be happy.