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

  • Home
  • SEARCH
  • 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 8791991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:55:08+00:00 2026-06-13T22:55:08+00:00

How to select file names from this kind of XML in a SQL Server

  • 0

How to select file names from this kind of XML in a SQL Server column?

  1. file name is in attribute VALUE only if high level tag is object with name File
    like this

    <Object NAME="File">
        <Parameter ID="1" NAME="Name" VALUE="\\mysvr\fiels\readme1.txt" />
    </Object>
    
  2. This sub-hierarchy can be placed on any level of xml (see example below)

  3. XML column can contain 0-N file names, I need list like this:

    id, filename
    --- ------------------------
     1  \\mysvr\fiels\readme1.txt
     1  \\mysvr\fiels\readme2.txt
     2  \\mysvr\fiels\readme3.txt
     2  \\mysvr\fiels\readme4.txt
    

Example of XML contents:

declare @t1 table
(   id int,
   x XML
)

insert into @t1 (id, x)
select 1,N'<root name="name" id="12">
<class1>
  <Object NAME="File">
              <Parameter ID="1" NAME="Name" VALUE="\\mysvr\fiels\readme1.txt" />
   </Object>
</class1>
<class1>
<subclass1>
<Object NAME="File">
              <Parameter ID="10" NAME="Name" VALUE="\\mysvr\fiels\readme2.txt" />
</Object>
<Object NAME="bitmap">
              <Parameter ID="11" NAME="my1" VALUE="bmp" />
</Object>
</subclass1>
</class1>
</root>'
union 
select 2,N'<root name="name" id="12">
<class1>
  <Object NAME="File">
              <Parameter ID="13" NAME="Name" VALUE="\\mysvr\fiels\readme3.txt" />
  </Object>
  <Object NAME="Font">
              <Parameter ID="22" NAME="Tahoma" VALUE="11" />
  </Object>
</class1>
<class1>
<subclass1>
  <Object NAME="File">
              <Parameter ID="14" NAME="Name" VALUE="\\mysvr\fiels\readme4.txt" />
  </Object>
</subclass1>
</class1>
</root>'
  • 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-13T22:55:09+00:00Added an answer on June 13, 2026 at 10:55 pm

    Try this:

    SELECT
        id,
        Filename = ObjPrm.value('@VALUE', 'varchar(100)')
    FROM @t1
    CROSS APPLY x.nodes('//Object[@NAME="File"]/Parameter') AS Tbl(ObjPrm)
    

    Gives me an output of:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this spool file having this kind of content. SQL> select file_name
I am trying to get the name of a file when I select it
I want to go to select a file from sdcard and upload it to
I need to get lots of data (file select , text, date ,...) from
I am trying to get names from a .txt file. I am using file('filename.txt')
I think it's kind of noob question but I'm new to SQL Server in
I have a query that aggregates and groupes from 2 different tables: SELECT co.name
Aside from parsing the function file, is there a way to get the names
I'm not sure this is possible without some kind of server interaction but I
I have this kind of mysql db (table name/fields) tbl_users : id, title, approved

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.