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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:57:09+00:00 2026-05-24T23:57:09+00:00

select * from tablename where CONVERT(xml, Sections).value(‘(/sections/section/@value)[1]’, ‘varchar(1)’) = ‘f’ will properly retrieve a

  • 0
select *
from tablename
where CONVERT(xml, Sections).value('(/sections/section/@value)[1]', 'varchar(1)') = 'f'

will properly retrieve a record with the following value in the Sections column:

<sections><section value="f" priority="4" /><section value="a" priority="4" /></sections>

But misses this:

<sections><section value="w" priority="4" /><section value="f" priority="4" /></sections>

Obviously this is the problem “/sections/section/@value)[1]” but I don’t understand the syntax and Google hasn’t been too helpful. I found some code that got me this far, but I don’t know how to modify it so that it will look through all tags instead of just the first one. I tried dropping the [1] but that gave the following error:

XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
  • 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-24T23:57:10+00:00Added an answer on May 24, 2026 at 11:57 pm

    You can use exist().

    select *
    from tablename
    where CONVERT(xml, Sections).exist('/sections/section[@value = "f"]') = 1
    

    If you want to use some dynamic value instead a hard coded f in the query you can use sql:variable().

    declare @Value varchar(10) = 'f'
    
    select *
    from tablename
    where CONVERT(xml, Sections).exist('/sections/section[@value = sql:variable("@Value")]') = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// First, prepare the statement, using placeholders $query = SELECT * FROM tableName; $stmt
if i apply a sql query statement to this table select * from context.tablename,
I have the code below: string SQL = select * from + TableName; using
SELECT ISNULL(MAX(ColumnName) + 1, 1) AS ColumnName FROM TableName How to write this query
This query is working fine: SELECT * FROM tablename where Date >'20091109' and id='11';
I just want to know what's the lambda expression of Select * from TableName
@EndDate = 2010-05-31 select * from TableName where OrderNo = 'AB103' and month(SendDate) =
Select * from tableName order by id desc limit 10 How to perform something
SELECT * FROM tableName WHERE (ISNULL(columnName,0) > 0) OR SELECT * FROM tableName WHERE
select * from tableName where somecode = '$$$$$$$&8Y~$$$$' when I ran this query in

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.