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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:27:25+00:00 2026-05-24T08:27:25+00:00

I am running the below query to extract data from an xml column…question is

  • 0

I am running the below query to extract data from an xml column…question is how to extract data that is in between ![CDATA[“”]] ?

select        
     CAST(xml as xml).value('(//@nodeName)[1]','nvarchar(20)') as NodeName,       
     CAST(xml as xml).value('(//![CDATA [prdDetDesc]])[1]','nvarchar(225)') as DetDesc,
     CAST(xml as xml).value('(//prdImg)[1]','nvarchar(1000)') as prdImage
from [dbo].[cmsContentXml])

I need to extract data that is present between [[“”]]

Thanks in advance

  • 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-24T08:27:25+00:00Added an answer on May 24, 2026 at 8:27 am

    There is nothing special with CDATA sections.

    declare @xml xml = 
    '<productDetailsDescription>
       <![CDATA[Candidates for this exam are professionals who typically pursue careers as database administrators, database developers, or business intelligence developers. Additionally, they can be people who do not work with Microsoft SQL Server as a part of their primary job functions but who want to show their breadth of technology experience, such as developers, systems administrators, and others. ]]>
     </productDetailsDescription>
     <productImage>/m/967558/40.jpg</productImage>
     <application>Slmnoasp</application>'
     
    select @xml.value('/productDetailsDescription[1]', 'nvarchar(225)')
    

    It also handles mixed values.

    declare @xml xml = 
    '<root>123<![CDATA[ABD]]>456</root>'  
     
    select @xml.value('/root[1]', 'nvarchar(10)')
    

    Result:

    (No column name)
    123ABD456
    

    Edit

    From a table instead of a variable with a cast to XML:

    select cast(xml as xml).value('/productDetailsDescription[1]', 'nvarchar(max)') as productDetailsDescription
    from YourTable
    

    Try it here: https://data.stackexchange.com/stackoverflow/q/108293/

    Edit 2

    You need to specify the node names in the query. You also have to decide if you should have the different nodes in the same column or if they should be in different columns. Below I show you how you can do both.

    declare @T table(xml nvarchar(max))
    
    insert into @T values
    ('<productDetailsDescription>
       <![CDATA[Candidates for this exam are professionals who typically pursue careers as database administrators, database developers, or business intelligence developers. Additionally, they can be people who do not work with Microsoft SQL Server as a part of their primary job functions but who want to show their breadth of technology experience, such as developers, systems administrators, and others. ]]>
     </productDetailsDescription>
     <productImage>/m/967558/40.jpg</productImage>
     <application>Slmnoasp</application>')
    
    insert into @T values
    ('<detailDescription>
       <![CDATA[Candidates for this exam are professionals who typically pursue careers as database administrators, database developers, or business intelligence developers. Additionally, they can be people who do not work with Microsoft SQL Server as a part of their primary job functions but who want to show their breadth of technology experience, such as developers, systems administrators, and others. ]]>
     </detailDescription>
     <productImage>/m/967558/40.jpg</productImage>
     <application>Slmnoasp</application>')
    
    -- Get detailDescription in a column of its own
    select 
      cast(xml as xml).value('/productDetailsDescription[1]', 'nvarchar(max)') as productDetailsDescription,
      cast(xml as xml).value('/detailDescription[1]', 'nvarchar(max)') as detailDescription
    from @T
    
    -- Get detailDescription in the same column as productDetailsDescription
    select 
      cast(xml as xml).value('/*[local-name()=("productDetailsDescription","detailDescription")][1]', 'nvarchar(max)') as detailDescription
    from @T
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have the query running on Postgres: SELECT * FROM addenda.users WHERE users.username
I have below SQL query: SELECT * FROM ( SELECT S.aCol, S.bCol, S.cCol, ROW_NUMBER()
I am running the simple query below select '''' + event_number + '''' +','
I have below query running on my users and chats table to join and
I am trying to speed up a long running query that I have (takes
I've a semi complex LINQ query that is running very slow. I do not
Upon running the below SQL statement (which works perfectly) I've found that all tables
I have a query that's running slow (in a loop of about 100 it
I have these two tables setup and the below query running. The problem is
I have a MySQL table of correlation data that I need to extract. I

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.