Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help ! XML problem (please see this updated version)


Help ! XML problem (please see this updated version)

Author
Message
onlo
onlo
SSC Veteran
SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)

Group: General Forum Members
Points: 207 Visits: 612
My problem : I have 2 tables
Table "Company"
Company_ID Member_IDs
101
201
Table "Member_info"
Member_ID Member_name
1011 Member_1011
1012 Member_1012
I want to have :
Company_ID Member_ID_name
101




201 ....

My problem :
(1)How can I make my sp or SQL statement to scan all the ID node of the "Company" table ? I mean all ID nodes within each records and then all records ?
(2)Now, I can only hard-code like this :
SELECT Company.Member_IDs.query('
element IDs
{
element ID { string((/IDs/ID)[1])},
element Name { sql:column("Member_info.Member_Name") }
}
') AS Result,
Company_ID
FROM Company, Member_info
WHERE Company.Member_IDs.value('(/IDs/ID)[1]','int')
= Member_info.Member_ID
onlo
onlo
SSC Veteran
SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)

Group: General Forum Members
Points: 207 Visits: 612
Dear all,

Please see my attachment file as the web site cannot display an XML file properly.
Attachments
My problem.doc (8 views, 20.00 KB)
Mark Cowne
Mark Cowne
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2091 Visits: 22794
select c.Company_ID,
(select r.value('.','int') as ID,
m.Member_name as Name
from c.Member_IDs.nodes('/IDs/ID') as x(r)
inner join Member_info m on m.Member_ID=r.value('.','int')
for xml path(''),root('IDs')) as Member_ID_name
from Company c



____________________________________________________

Deja View - The strange feeling that somewhere, sometime you've optimised this query before

How to get the best help on a forum

http://www.sqlservercentral.com/articles/Best+Practices/61537




onlo
onlo
SSC Veteran
SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)

Group: General Forum Members
Points: 207 Visits: 612
Dear Mark,

It worked.

You are very brilliant.

Thanks a lot.

Are you US citizen ?
Mark Cowne
Mark Cowne
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2091 Visits: 22794
Thanks, I'm a UK citizen.

____________________________________________________

Deja View - The strange feeling that somewhere, sometime you've optimised this query before

How to get the best help on a forum

http://www.sqlservercentral.com/articles/Best+Practices/61537




onlo
onlo
SSC Veteran
SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)

Group: General Forum Members
Points: 207 Visits: 612
I am a Chinese and living in Hong Kong.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search