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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:16:45+00:00 2026-06-06T13:16:45+00:00

I currently have this code which stores XML into an XML-type column called data,

  • 0

I currently have this code which stores XML into an XML-type column called data, in a table called Storage.

    CREATE TABLE Storage
(
    ID INT IDENTITY(1,1) PRIMARY KEY,
    data XML NOT NULL
)

GO

INSERT INTO Storage(data) 
VALUES('<footballteams>   
    <team manager="Benitez">     
        <name>Liverpool</name>     
        <ground>Anfield</ground>   
    </team>   
    <team manager="Mourinho">     
        <name>Chelsea</name>     
        <ground>Stamford Bridge</ground>   
    </team>   
    <team manager="Wenger">     
         <name>Arsenal</name>     
         <ground>Highbury</ground>   
    </team> 
</footballteams>'); 

I would like to create a view called Football View which shreds the data and displays it in the form: FootballView(TeamName,Manager,Ground).

I have shredded full documents using the .nodes() method into table columns before, but it seems to be more challenging when creating a view (I have my reasons for using views). The problem is that previously I just called .nodes on a variable @input which was DECLARE’d as xml = ‘xmlcontent’ but with views this can’t be done, and I want to parse XML contained within the Storage table column.

Any ideas? Thanks in advance.

EDIT:

Previously, if I had shredded into tables this would be the code I use:

SELECT     
        TeamName = Foot.value('(name)[1]', 'varchar(100)'),     
        Manager = Foot.value('(@manager)', 'varchar(100)'),     
        Ground = Foot.value('(ground)[1]', 'varchar(100)')   
FROM     
        @input.nodes('/footballteams/team') AS Tbl(Foot)

EDIT2: This is the output I expect.

Expected Output

  • 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-06T13:16:46+00:00Added an answer on June 6, 2026 at 1:16 pm

    You need to use CROSS APPLY

    SELECT     
            TeamName = Foot.value('(name)[1]', 'varchar(100)'),     
            Manager = Foot.value('(@manager)', 'varchar(100)'),     
            Ground = Foot.value('(ground)[1]', 'varchar(100)')   
    FROM    
        Storage S 
            CROSS APPLY data.nodes('/footballteams/team') AS Tbl(Foot)
    

    CROSS APPLY and OUTER APPLY allow you to effectively join to a collection of XML in the current data set.

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

Sidebar

Related Questions

I currently have this code which reads the first field in a database record
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
I have this following code which will return all the current semesters. How do
Ok I currently have this code public int i = 0; //this is outside
Hello I currently have this code checking if a cookie exists, it works all
I currently have this useful code that I found elsewhere on StackOverflow: form.DrawToBitmap(bmp, new
I currently have this piece of code: NSString *strURL = [NSString stringWithFormat:@http://www.sample.com /phpFile.php?firstname=%@,txtfirstName.text]; NSString
Using dotnet 2.0. I currently have code like this : DataView dv = new
Is there a better way to do this jquery code? Currently I have to
I have an Entity in Code First Entity framework that currently looks like this:

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.