views:

31

answers:

1

Hi I get problem retrieve XML data from SQL2000 server.

The table structure is as following:

ID   Name   XML
1    Name1  <Root><DATA1>1-Data1</DATA2><DATA1>1-Data2</DATA2></Root>
2    Name2  <Root><DATA1>2-Data1</DATA2><DATA1>2-Data2</DATA2></Root>
3    Name3  <Root><DATA1>3-Data1</DATA2><DATA1>3-Data2</DATA2></Root>

How can I get the result out like this:

ID   Name   Data1   Data2
1    Name1  1-Data1 1-Data2
2    Name2  2-Data1 2-Data2
3    Name3  3-Data1 3-Data2

I am new SQL2000. Is such query possible in SQL2000?

Thanks for your help in advance!

A: 

In SQL Server 2005 and up, this would be no problem at all - if your XML very even valid, that is:

<Root> 
    <DATA1>1-Data1</DATA2>
    <DATA1>1-Data2</DATA2>
</Root>

You can't have an opening tag of <DATA1> and then a closing tag of </DATA2> - this is not well-formed XML and no XML parsing engine will be able to handle it....

But SQL Server 2000 doesn't really support XML processing (it can import XML and spit out XML, but it can't really process it) - I'm afraid you're out of luck with the 2000 version.

marc_s