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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:51:22+00:00 2026-05-19T04:51:22+00:00

I have a bunch of rows in a database that all contain an element

  • 0

I have a bunch of rows in a database that all contain an element that looks like the following

<ModuleData ModuleFieldGU="4dcdde21-40c6-4d1a-9fe1-1841935d3a68">
 <DateTime>0001-01-01T00:00:00</DateTime>
 <Boolean>false</Boolean>
 <Int>0</Int>
 <Varchar>Test District</Varchar>
 <GUID>00000000-0000-0000-0000-000000000000</GUID>
 <Modified>true</Modified>
 </ModuleData>

I need to look across all of these and match where the varchar element/node is set to a certain value.

I’ve tried both of the followuing, and neither seem to be working for me

SELECT 
    Data.Element.value('(@Varchar)[1]', 'varchar(255)') as UserEmail 
    FROM
        ModuleData
    CROSS APPLY
        XML_DATA.nodes('/ModuleData') AS Data(Element)
    WHERE
    Data.Element.value('(@Varchar)[1]', 'varchar(255)') = @UserEmail

and

SELECT 
   CAST(XML_DATA.query('data(/ModuleData[@Varchar])') as varchar(255)) as UserEmail
FROM 
   ModuleData
WHERE 
   XML_DATA.exist('/ModuleData[@Varchar = sql:variable("@UserEmail")]') = 1

but it isn’t working. I’m not really up to speed with the finer points of using XQuery to get data out of XML. Can anyone point me in the correct direction?

  • 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-19T04:51:22+00:00Added an answer on May 19, 2026 at 4:51 am

    The correct XPath should be:

    /ModuleData/Varchar
    

    Because it’s an element, not an attribute.

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

Sidebar

Related Questions

I have a SQL query that outputs a bunch of rows that match a
I have a small app that lists a bunch of items in a database.
I have a bunch of rows in a form like this <tr> <td nowrap><input
I have a bunch of functions with signatures like: FUNCTION func1 (par1 IN VARCHAR2,
I have a bunch of html with lines like this: <a href=# rel=this is
I have a bunch of generic code that is used a lot, which i'd
I have a bunch of python methods that follow this pattern: def delete_session(guid): conn
There's a little script that grabs a bunch of data from a database, and
I need to delete a bunch of rows from my database under a certain
I have a bunch of users making ad-hoc queries into a database running SQL

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.