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

  • Home
  • SEARCH
  • 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 3405028
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:27:18+00:00 2026-05-18T05:27:18+00:00

Hello from an SQL nO0b, I have three Select statements I want to join:

  • 0

Hello from an SQL nO0b,
I have three Select statements I want to join:

Select 2 is a FOR XML Select to which I want to append Selects 1 & 3 (which simply display some text) as a kind of header/footer.

All three Selects work as intended and form three parts of a nicely-formed podcast .xml, but I need them to end up in one result so I can eventually save it to an .xml file (which will be my next headache, I suppose).

I have tried permutations of +, UNION, and JOIN that my inexperienced mind can come up with, but to no avail.

Select #1 (simply some text)

Select  '<?xml version=''1.0''?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"  xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <atom:link href="http://www.mysite.com/podcast/podcast.xml" rel="self" type="application/rss+xml" />
  <itunes:image href="http://www.mysite.com/Portals/0/Images/Audio/podcast_logo.jpg"/>
  <link>http://www.mysite.com/Audio.aspx</link>
<title>My Podcast</title>
<description>My Podcast's Description</description>
<language>en-us</language>
<copyright>&#xA9; 2010</copyright>
      <itunes:subtitle>Subtitle</itunes:subtitle>
      <itunes:owner>
        <itunes:name>Name</itunes:name>
        <itunes:email>user@domain.com</itunes:email>
      </itunes:owner>
      <itunes:category text="Religion &amp; Spirituality">
        <itunes:category text="Christianity" />
      </itunes:category>
      <itunes:explicit>No</itunes:explicit>
      <ttl> 120 </ttl>'   

Select #2 (my data)

Select 
(Select Cast(FieldValue as nvarchar(max)) from dbo.UserDefinedData where UserDefinedFieldId = 305 and UserDefinedRowId = item.UserDefinedRowId) as [title]
,(Select 'Today''s Program is ' + Cast(FieldValue as nvarchar(max)) from dbo.UserDefinedData where UserDefinedFieldId = 305 and UserDefinedRowId = item.UserDefinedRowId) as [description]  
,(Select Cast(Cast(FieldValue as nvarchar(max)) as DateTime) from dbo.UserDefinedData where UserDefinedFieldId = 306 and UserDefinedRowId = item.UserDefinedRowId) as [pubdate]
,(Select 'http://www.mysite.com/Portals/0/AudioFiles/RadioArchives/' + Cast(FieldValue as nvarchar(max)) from dbo.UserDefinedData where UserDefinedFieldId = 308 and UserDefinedRowId = item.UserDefinedRowId) as [guid]
 From 
dbo.UserDefinedRows item
 Where 
ModuleId = 820
 and UserDefinedRowID in (select UserDefinedRowID from UserDefinedData where UserDefinedFieldID = 306 and Cast(Cast(FieldValue as nvarchar(max)) as DateTime) between '2010-Nov-11' and '2010-Nov-18') 
 Order By 
[pubdate] DESC
for XML AUTO,ELEMENTS

Select #3 (more text)

Select '</channel>
</rss>'

(I am using MS SQLSMS 2008.)
(The complex nature of the second select statement is due to the fact that it is retrieving data from a DotNetNuke “User-Defined Table/Form & List” which must first be “flattened”.)

Any help would be appreciated, Thanks.

  • 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-18T05:27:19+00:00Added an answer on May 18, 2026 at 5:27 am
    Declare @V1 VarChar(Max), @V2 VarChar(Max), @V3 VarChar(Max)
    
    Select @V1 = ...
    
    Set @V2 = (Select ...)
    
    Select @V3 = ...
    
    Select @V1+@V2+@V3
    

    Alternatively, cast #1 and #3 to XML.

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

Sidebar

Related Questions

Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello we have an SQL server application running over a low bandwith connection. We
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello I was writing a Regular Expression (first time in my life I might
Hello can anybody solve this please I'm creating the object in the action class
Hello I am compiling a program with make but I get the error of
Hello , I am currently working on the student association's website. The student's association
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello there and Merry Christmas !!! I am new to WPF and I am

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.