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 8181061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:23:47+00:00 2026-06-07T00:23:47+00:00

the task I want to achieve is import XML file into SQL Server. Once

  • 0

the task I want to achieve is import XML file into SQL Server. Once prepare the empty table I would load the entire xml file and fill that table. Googling I found that SQL Bulk Insert is suitable so I tested the following code which runs fine:

INSERT INTO Products (sku, product_desc)
SELECT X.product.query('SKU').value('.', 'INT'),
       X.product.query('Desc').value('.', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
    BULK 'C:\Products.xml',
    SINGLE_BLOB) AS T(x)
    ) AS T(x)
CROSS APPLY x.nodes('Products/Product') AS X(product);

My XML file count around 1860 nodes, (30kb), quite small but the above procedure takes over 5 minutes to import the whole file. Is there any chance to spee up this process?
I’ve also read that SQL Server 2008 have a bug which affect the bulk object.
Any hints?

  • 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-07T00:23:48+00:00Added an answer on June 7, 2026 at 12:23 am

    Try this – I imported a file with 4’096 records from disk in just 53 seconds (on a regular average desktop machine – no high-perf server):

    -- declare XML variable
    DECLARE @InputXML XML
    
    -- import file from disk
    SELECT @InputXML = CAST(x AS XML)
    FROM OPENROWSET(BULK 'D:\temp\Products.xml', SINGLE_BLOB) AS T(x)
    
    -- parse XML using XQuery and insert into the table    
    INSERT INTO dbo.Products (sku, product_desc)
        SELECT 
            product.value('(SKU)[1]', 'int'),
            product.value('(Desc)[1]', 'varchar(30)')
        FROM @InputXML.nodes('Products/Product') AS X(product)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using JAVA framework i want to achieve the following task. hot code(jar) deployment which
I want to achieve a pretty simple task, but none of the solutions here
I'm developing a Silverlight 4 application and want to achieve a seemingly easy task:
This should be an absurdly easy task: I want to take each line of
I want to make Task in Google Calendar using Google Calendar API : c#.
I want to create Task in Google Calendar using Google Calendar API.Using C#. Looking
I want to set up a rake task to fill my CouchDB with fixtures
I want to setup a serialized task queue using NSOperationQueue but I'm a little
I want to write a simple task which will update and commit source code
I want to continue one task because my head has some problem with a

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.