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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:34:31+00:00 2026-06-09T18:34:31+00:00

I am trying to write a query that pulls out the names of all

  • 0

I am trying to write a query that pulls out the names of all of the parameters in my report server. The parameters data is stored as XML in an ntext field so I don’t think I can use xquery on it.

What I initially started doing was making case statements for each parameter name I expect to find but, this is going to be tedious and I don’t think the report developers were totally consistent with parameter names (and in fact that is one of my reasons for wanting the query).

Here is what i have so far, which is pretty simplistic:

SELECT [Path], [Name], CreationDate, ModifiedDate, Parameter, 
CASE WHEN Parameter LIKE '%<Name>UserId</Name>%' THEN 'Yes' ELSE 'No' END AS  'UserId', 
CASE WHEN Parameter LIKE '%<Name>Country</Name>%' THEN 'Yes' ELSE 'No' END AS 'Country',
CASE WHEN Parameter LIKE '%<Name>Office</Name>%' THEN 'Yes' ELSE 'No' END AS 'Office'
FROM dbo.Catalog
WHERE type IN (2, 4)
AND [path] NOT LIKE '/Enterprise Reports%' 
AND [Path] NOT LIKE '/Email Subscription%'
ORDER BY [Path]

What I think I want is something more like this:

SELECT [Path], [Name], CreationDate, ModifiedDate, Parameter.query(/Parameters/Parameter/Name)
FROM dbo.Catalog
WHERE type IN (2, 4)
AND [path] NOT LIKE '/Enterprise Reports%' 
AND [Path] NOT LIKE '/Email Subscription%'
ORDER BY [Path]

The problem is, it’s ntext, not xml. Can I just use convert on that?

The other problem is, I don’t know the xquery syntax to pull out the name field of the many parameters within the XML.

The document’s schema is very simple:

<Parameters>
   <Parameter>
      <Name>Some name</Name>
      ...some more fields i don't care about...
   </Parameter>
   <Parameter>
      <Name>Another name</Name>
   </Parameter>
   ...more parameters, etc.
</Parameters>

I just want a list of what is in the names.

There can be many nodes and each one has a single node as a child.

UPDATE:

It seems like Nodes() should help me but I am struggling to take the examples on Books Online and a Simple Talk article and apply it to my situation. Here is what I have so far:

SELECT [Path], [Name], CreationDate, ModifiedDate, Parameter, 
CASE WHEN Parameter LIKE '%<Name>UserId</Name>%' THEN 'Yes' ELSE 'No' END AS 'UserId', 
CASE WHEN Parameter LIKE '%<Name>Country</Name>%' THEN 'Yes' ELSE 'No' END AS 'Country',
CASE WHEN Parameter LIKE '%<Name>Office</Name>%' THEN 'Yes' ELSE 'No' END AS 'Office'
, CAST(Parameter AS XML).nodes('/Parameters/Parameter/Name')
FROM dbo.Catalog
WHERE type IN (2, 4)
AND [path] NOT LIKE '/Enterprise Reports%' 
AND [Path] NOT LIKE '/Email Subscription%'
ORDER BY [Path]
  • 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-09T18:34:32+00:00Added an answer on June 9, 2026 at 6:34 pm

    The answer to your first question is: yes, it’s as easy as a CONVERT(xml, Parameter). Assuming that it’s well formed XML, it’ll convert just fine

    The second question is going to involve the nodes() method of the XML data type. Read all about it: nodes().

    Edit:

    Now that I’m in a position to test, here’s what I came up with:

    WITH cte AS (
        SELECT   CAST(parameter AS XML) AS parameter
        FROM     [dbo].[Catalog] AS c
    )
    SELECT  p.value('(./Name)[1]', 'nvarchar(50)')
    FROM    cte AS c
    CROSS APPLY c.Parameter.nodes('/Parameters/Parameter') AS T ( p )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a simple correlated sub query that deletes all records
I am trying to write a SQL query that pulls from 3 tables and
I'm trying to write a HQL/Criteria/Native SQL query that will return all Employees that
Im trying to write a query that will find and display all of my
I am trying to write a query that looks through all combo_items and only
I'm trying to write a query that extracts and transforms data from a table
I am trying to write a query that pulls multiple fields and assigns aliases
I am trying to write a query in Postgresql that pulls a set of
I am trying to write a query to pull all the rows that contain
I'm trying to write a query that will return the closest match from a

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.