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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:21:02+00:00 2026-05-31T21:21:02+00:00

I have a requirement to return xml as follow <row id=1> <cell>1</cell> <cell>setup/pagemst</cell> <cell>Page

  • 0

I have a requirement to return xml as follow

<row id="1">
<cell>1</cell>
<cell>setup/pagemst</cell>
<cell>Page Master</cell>
</row>
<row id="2">
<cell>2</cell>
<cell>setup/modules</cell>
<cell>Module Master</cell>
</row>

I used the following Query but it does not work

select 
pageid id,pgurl cell,pgname cell
from m_pages
for xml raw

The same column names for all columns works fine in oracle but not in SQL Server 2005. Any Ideas ?

Thanks in advance
deb

  • 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-31T21:21:03+00:00Added an answer on May 31, 2026 at 9:21 pm

    Use the FOR XML PATH syntax available in SQL Server 2005 and newer – try something like this:

    DECLARE @table TABLE (PageID INT, PageUrl VARCHAR(50), PageName VARCHAR(50))
    
    INSERT INTO @table VALUES(1, 'setup/pagemst', 'Page Master'),(2, 'setup/modules', 'Module Master')
    
    select 
        PageID AS '@id',
        PageID AS 'cell',
        '',
        PageUrl AS 'cell',
        '',
        PageName AS 'cell'
    from @table
    FOR XML PATH('row')
    

    Gives me the output in the end:

    <row id="1">
      <cell>1</cell>
      <cell>setup/pagemst</cell>
      <cell>Page Master</cell>
    </row>
    <row id="2">
      <cell>2</cell>
      <cell>setup/modules</cell>
      <cell>Module Master</cell>
    </row>
    

    The FOR XML PATH syntax allows you to define what values to return as XML attributes (... AS '@id') or XML elements. By adding “empty” lines between the elements, you prevent the output from being merged / concatenated
    into a single <cell>....</cell> XML element

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

Sidebar

Related Questions

For a project we have a requirement to create an interfacedefinition that will return
I have requirement of specifying web part connections in onet.xml. So when site is
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
I have a requirement to create some xml structs (to borrow a C-phrase) in
I have WCF rest service returning XML/RSS feeds. Some methods return data contracts, some
I have the following XML structure: <?xml version=1.0 ?> <course xml:lang=nl> <body> <item id=787900813228567
We have a requirement to populate a master table which consists of columns from
I have the following weird requirement. I am given: A list of some method
In my ASP.NET MVC project I have a requirement to return certain pages in
I have a requirement wherein I have to change the text of the return

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.