SQL Server 2000/ SQLXML

  • As with most software topics these days, there is a plethora of information on producing XML format through SQL searches. However, I am unable to find a SQL search format for producing results in the following basic format:

    <Root>

    <attribute1>element<attribute2>

    <attribute2>element<attribute2>

    </Root>

    Can anyone assist me with the query required for the SQL Query Analyser?

  • Have a look in BOL at FOR XML EXPLICIT.

    Quite powerfull.

    It allowes you to mix and match nodes with attributes.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • ..will do, nice to know things are still operational in Johies after the nail biter against Scotland on the w/e

  • lol.

    If this topic turns to rugby, you'll have most American viewrs searching through BOL for the RUGBY function

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • That's the function that takes rug marketing data and ensures a break down by type...right?

  • That's the one.

    Only avaliable in 2K South African Edition.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Thought so. They only give us the buggy versions of SQL here in the US. Think their still mad about the anti-trust stuff and the day Bill got his just desserts (pie-in-the-face-day).

  • ..you guys have digressed from my query, but it looks like FOR XML should do the trick.

    ..I know this is subjective, but I reckon passing the ball forward during sport reduces the complexity of the game

  • This is true but indo so, it keeps a lot of countries out of the sport.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • True, but should the objectives of a sporting code be to be played by and appeal to all nations. It is great for athletics and such, however for certain sports I think it is good to retain ethnic and regional traditions and keep 'em tribal. Talk about digression....!

  • Thanks Crispin, the Query I was looking for is:

    Select * from (tablename) for XML Auto, Elements

    Cheers

  • ahhh. That was the easy route 🙂

    What I thought you want was:

    <ROOT>

    <ElementName ATTR1="xxx">Some Value1</ElementName>

    <ElementName ATTR1="yyy">Some Value2</ElementName>

    <ElementName ATTR1="aaa">Some Value3</ElementName>

    <ElementName ATTR1="bbb">Some Value4</ElementName>

    </ROOT>

    You can get a lot done with EXPLICIT but it took me a while to understand it.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • a boer maak a plan!

    loosely translated = a farmer will make a plan!

  • Maar n engelsman maak a plan wat werk... (But an englishman make a plan that works)

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Fascinating have I fallen into a alt.sports.boer newsgroup by mistake?

    You'll need to do

    Select * from (tablename) as ROOT for XML Auto, Elements

    if you want <ROOT> around your output.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply