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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:04:04+00:00 2026-05-15T18:04:04+00:00

I am using SQL Server 2008 Enterprise + VSTS 2008 + C# + .Net

  • 0

I am using SQL Server 2008 Enterprise + VSTS 2008 + C# + .Net 3.5 + ASP.Net + IIS 7.0 to develop a simple web application. In my database table, I have a XML type column. The content is like below,

I want to get AdditionalInfoList of all rows in the table if Title contains “software engineer” or Info contains “Software Development”. My question is how to write such query efficiently?

<People>
  <Item Name="Username" Value="George" />
  <Item Name="Info" Value="Software Development Information" />
  <Item Name="Title" Value="Software Engineer in Backend" />
  <AdditionalInfoList>
    <AdditionalInfoListItem Guid="xxx" type="type1" />
    <AdditionalInfoListItem Guid="yyy" type="type2" />
  </AdditionalInfoList>
</People>
  • 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-05-15T18:04:05+00:00Added an answer on May 15, 2026 at 6:04 pm

    You need to do something like this:

    SELECT
        t.ID, -- or whatever you need from the table where the XML is located
        tbl.People.query('AdditionalInfoList')
    FROM
        dbo.YourTable  t
    CROSS APPLY
        t.(xmlcolumn).nodes('/People') AS Tbl(People)
    WHERE
        tbl.People.value('(Item[@Name="Info"]/@Value)[1]', 'varchar(50)') LIKE '%Software Development%'
        OR
        tbl.People.value('(Item[@Name="Title"]/@Value)[1]', 'varchar(50)') LIKE '%Software Engineer%'
    

    That should give you all the entries you’re interested in.

    Explanations:

    The CROSS APPLY creates a “dummy” table which you need to give a name to – here: Tbl(People). What that name is doesn’t really matter, and it’s not case sensitive, so Tbl and tbl are identical.

    If you want to Guid and the type as separate values from the <AdditionalInfoList>, you need to use this query here:

    SELECT
        t.ID,
        --tbl.People.value('(Item[@Name="Info"]/@Value)[1]', 'varchar(50)') AS 'Info',
        --tbl.People.value('(Item[@Name="Title"]/@Value)[1]', 'varchar(50)') AS 'Title'
        Adtl.Info.value('(@Guid)[1]', 'varchar(50)') AS 'GUID',
        Adtl.Info.value('(@type)[1]', 'varchar(50)') AS 'Type'
    FROM
        @table t
    CROSS APPLY 
        t.xmlcolumn.nodes('/People') AS Tbl(People)
    CROSS APPLY 
        Tbl.People.nodes('AdditionalInfoList/AdditionalInfoListItem') AS Adtl(Info)
    WHERE
        Tbl.People.value('(Item[@Name="Info"]/@Value)[1]', 'varchar(50)') LIKE '%Software Development%'
        OR
        Tbl.People.value('(Item[@Name="Title"]/@Value)[1]', 'varchar(50)') LIKE '%Software Engineer%'
    

    You basically have to do a second CROSS APPLY (that’ll hurt your performance!) to get the “additional info” list for each of the entries from Tbl.Person and extract the Guid and the type value from that.

    Check out the SQL Server 2005 XQuery and XML DML introduction – about in the middle of the article, there’s a section on how to use the .nodes() function. Very helpful!

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

Sidebar

Related Questions

I am using .Net 2.0 + SQL Server 2005 Enterprise + VSTS 2008 +
I am using .Net 2.0 + SQL Server 2005 Enterprise + VSTS 2008 +
I am using VSTS 2008 + .Net 3.5 + ASP.Net to develop a simple
Setup: IIS on Windows 2008 Server R2 Enterprise, SQL Server 2008 R2 Enterprise, ASP.NET
I am using SQL Server 2008 Enterprise. I have created a very simple test
I am using ASP.Net + .Net 3.5 + VSTS 2008 + IIS 7.0 +
I am using SQL Server 2008 Enterprise with VSTS 2008, and I am developing
I am using VSTS 2008 + C# + .Net 3.5 + ASP.Net + SQL
I am using SQL Server 2008 Enterprise. I have a table and one of
We are using SQL Server 2008 Enterprise version. We have a large table FooTable

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.