Urgent: Help regarding "For XML" Clause

  • Hello all, I am working on a task in which, I need to generate XML output out of a SQL Database. I am using FOR XML clause and generating output using BCP. I have XML file but this file is without LineFeed.

    There are no Linefeeds after each End Tag in the XML. How can I add Line-feed into this XML??

    Please this is urgent. Respond at your earliest.

    Thank you very much.

    -RP

    -RP
  • For XML won't do line-feeds because XML files don't need them. That's what tags are for.

    Why do you need line-feeds in XML?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hello GSquared,

    Yes, we don't need it for XML, but i need to add line feed after every end tag. We are sending these xml files to third party for further processing and they need us to insert line feed after every end tag because of large size of the files. They need to truncate these files to process further.

    So, I need to add line feed after each end tag on XML.

    Is it feasible?

    Thank you for your response.

    Regards,

    -RP

    -RP
  • If you store the XML as varchar(max) instead of as XML, you could use Replace to add line-breaks after certain tags. Would that do what you need?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • That doesn't make sense. Adding characters to a file because it is too big! How do you go about truncating a self-describing file?

    You can't do this with the FOR XML statement and BCP. The only thing I can think of is to open the file and programatically add the line feeds.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 5 posts - 1 through 4 (of 4 total)

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