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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:46:57+00:00 2026-06-09T21:46:57+00:00

I need import an XML file into a SQL Server 2008 R2database. So, I

  • 0

I need import an XML file into a SQL Server 2008 R2database.

So, I have query with hardcoded XML data:

DECLARE @xml XML
SET @xml='
<goods_item>
<goods_level>1</goods_level>
<goods_isgroup>1</goods_isgroup>
<goods_code>51852</goods_code>
<goods_name></goods_name>
<goods_parent></goods_parent>
<goods_art></goods_art>
<goods_buhart></goods_buhart>
<goods_inpack>0</goods_inpack>
<goods_packtxt></goods_packtxt>
<goods_country></goods_country>
<goods_gtd></goods_gtd>
<goods_nds>0</goods_nds>
<goods_unit></goods_unit>
</goods_item>
<goods_item>
<goods_level>1</g    oods_level>
<goods_isgroup>1</goods_isgroup>
<goods_code>51852</goods_code>
<goods_name></goods_name>
<goods_parent></goods_parent>
<goods_art></goods_art>
<goods_buhart></goods_buhart>
<goods_inpack>0</goods_inpack>
<goods_packtxt></goods_packtxt>
<goods_country></goods_country>
<goods_gtd></goods_gtd>
<goods_nds>0</goods_nds>
<goods_unit></goods_unit>
</goods_item>'

And it works fine. But how can I change hardcode XML data to path to XML file?

Something about this:

SET @xml='D:\xml1.xml'
  • 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-09T21:46:59+00:00Added an answer on June 9, 2026 at 9:46 pm

    You could first import it into a temporary table like this:

    declare @insert nvarchar(1000), @pathname varchar(200), @xml xml
    
    set @pathname = 'your path here'
    
    create table #tmp_xml(xmldata xml)
    
    set @insert = 'INSERT INTO #tmp_xml(xmldata) SELECT bulkcolumn 
          FROM OPENROWSET (BULK N''' + @pathname+ ''', SINGLE_BLOB) AS data'
    
    exec sp_executesql @insert
    
    select @xml = xmldata from #tmp_xml
    
    -- read, parse xml here ....
    drop table #tmp_xml
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to import the .sql file of PHP myadmin into SQL Server 2008.
I have an XML file whose contents I need to import into a Microsoft
I need to import a database into a SQL Server instance using a batch
In my app I need to import a 100MB xml file into a Core
i need to import a mysql file into my access db. how do i
I need to import data from *.dmp file say mydump.dmp. What I'm doing is:
I have a data table in SQL 2008 R2 which is used to store
I'm writing a windows service that import an XML file into a SQLite database.
We need to parse an XML file with XSLT into a CVS file. The
I need to import some Excel spreadsheets into Java objects. I will use POI

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.