Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:40:19+00:00 2026-06-09T12:40:19+00:00

I have to shred around 25 – 30 XMLs into my SQL Server 2005

  • 0

I have to shred around 25 – 30 XMLs into my SQL Server 2005 database (the total size would be around 10 MB). And I need this logic to run automatically as soon as new xml files are copied to the server.

Ive read many posts on this site and also other sites, but can’t still conclude on what must I use to shred data.

Pls let me know which option must I should go with

  1. SqlBulk Copy
  2. C# deserialization
  3. SSIS

I have to create C# classes for my data models. So C# deserialization was my first choice.
But pls let me know which option will be right from a performance perspective.

Another thing I forgot to mention was the structure of the XML files will vary. It wouldnt be the same. I will have tables that will have all the columns that could possibly be populated. But the xmls will not have all the data at all times.

Sample of the xml

<?xml version="1.0" encoding="utf-8"?>
<estateList date="2012-08-06T12:17:05">
  <uniqueID>22XXln</uniqueID>
  <category name="Apartment" /> 
  <listingAgent>
     <name>DIW Office</name>  
     <telephone type="BH">96232 2345</telephone> 
     <telephone type="BH">9234 2399</telephone>
     <email>abcd@abc.com</email>    
  </listingAgent>
  <inspectionTimes /> 
  <description>AVAILABLE NOW. </description> 
  <price>0</price>  
  <address display="yes">      
    <street>Lachlsan Street</street>        
    <ImagesContainer>        
       <img id="m" modTime="2012-08-06-12:17:05" url="http://images/2409802.jpg" format="jpg" /> 
       <img id="a" modTime="2012-08-06-12:17:05" /> 
    </ImagesContainer>     
  </address>
</estateList>

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:40:21+00:00Added an answer on June 9, 2026 at 12:40 pm

    Given you have your XML in a SQL variabe, you can pretty easily parse out most of the info using straight T-SQL with the XQuery support added in SQL Server 2005.

    Try something like:

    DECLARE @Input XML = '<estateList date="2012-08-06T12:17:05">
      <uniqueID>22XXln</uniqueID>
      <category name="Apartment" /> 
      <listingAgent>
         <name>DIW Office</name>  
         <telephone type="BH">96232 2345</telephone> 
         <telephone type="BH">9234 2399</telephone>
         <email>abcd@abc.com</email>    
      </listingAgent>
      <inspectionTimes /> 
      <description>AVAILABLE NOW. </description> 
      <price>0</price>  
      <address display="yes">      
        <street>Lachlsan Street</street>        
        <ImagesContainer>        
           <img id="m" modTime="2012-08-06-12:17:05" url="http://images/2409802.jpg" format="jpg" /> 
           <img id="a" modTime="2012-08-06-12:17:05" /> 
        </ImagesContainer>     
      </address>
    </estateList>'
    
    SELECT
        EstateListDate = EstL.value('@date', 'datetime'),
        UniqueID = EstL.value('(uniqueID)[1]', 'varchar(20)'),
        Category = EstL.value('(category/@name)[1]', 'varchar(20)'),
        ListingAgentName = EstL.value('(listingAgent/name)[1]', 'varchar(50)'),
        ListingAgentTel = EstL.value('(listingAgent/telephone)[1]', 'varchar(50)'),
        ListingAgentEMail = EstL.value('(listingAgent/email)[1]', 'varchar(250)'),
        [Description] = EstL.value('(description)[1]', 'varchar(250)'),
        Price = EstL.value('(price)[1]', 'decimal(14,2)'),
        DisplayAddress = EstL.value('(address/@display)[1]', 'varchar(10)'),
        AddressStreet = EstL.value('(address/street)[1]', 'varchar(100)')
    FROM @input.nodes('/estateList') AS Tbl(EstL)
    

    and you should get:

    enter image description here

    This data could be easily inserted into a table. And this query could be run against any number of XML files on disk, using a fairly easy SSIS package (enumerate the XML, load each into a SQL variable, parse it, insert data into tables etc.)

    BUT: the challenging part is going to be questions like:

    • can there be more than one listing agent? And if yes : how to handle that?
    • can there be more than one phone number and how to deal with that?
    • what do to with the multiple images per address

    and so forth ….

    Update: this query here would extract the UniqueID and each complete <img> tag’s information from that XML input and display it (or insert it into another table):

    SELECT
        UniqueID = @input.value('(/estateList/uniqueID)[1]', 'varchar(20)'),
        ImageID = Images.value('(img/@id)[1]', 'varchar(20)'),
        ImageModTime = Images.value('(img/@modTime)[1]', 'varchar(50)'),
        ImageFormat = Images.value('(img/@format)[1]', 'varchar(20)'),
        ImageURL = Images.value('(img/@url)[1]', 'varchar(250)')
    FROM 
        @input.nodes('/estateList/address/ImagesContainer') AS Tbl(Images)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have around 3 websites residing in a server which is being shared with
I have found this script scattered around my Wordpress uploads folder on my shared
I have been playing around with a quite complex SQL Statement for a few
I have started to play around with boost python a bit and ran into
I have a shared MS Sql 2008 database with my hosting provider and MS
I have done my best to install a copy of SQL Server 2008, but
I have been trying to wrap my head around why this is happening but
I have a problem with my code where agents moving around suddenly disappear. This
I've been searching around for an answer for this for a while and have
I'm trying to shred XML files that have an unusual layout, because items are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.