Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Union Operation With for xml Path in sql server 05

Author  Topic 

csri
Starting Member

45 Posts

Posted - 2008-07-02 : 11:59:21
Dear All
I want to union two select statements with for xml path.
Is it possible.I want to display data from both tables using union and display it.Any one please help
Eg

select g.groupname,NULL,NULL,NULL,NULL
from groups g
for xml path(''),Type
UNION
SELECT Name,Terminal,Code,NULL,CityName
from NAME n
for xml path(''),Type


Thanks
sri

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-07-02 : 12:22:37
Would this work?:

select groupname, A, B, C, D
from --subquery
(select g.groupname,NULL as A,NULL as B,NULL as C,NULL as D
from groups g
UNION
SELECT Name,Terminal,Code,NULL,CityName
from NAME n) subquery
for xml path(''),Type


e4 d5 xd5 Nf6
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-02 : 13:48:40
quote:
Originally posted by csri

Dear All
Can anyone tell me how to do this.Struggling since 5 hours.

Thanks
sri


can you show how xml node should appear and also some sample data from your tables?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-02 : 14:24:38
you want to repeat both group names with all detail?
Go to Top of Page
   

- Advertisement -