Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2002
    Posts
    74

    Unanswered: Merge two files in SQL Server

    Hi folks!

    I have a question - do you know if there is a sql command to merge two files? Basically, I want to merge the header for the xml file with actual xml data (generated via SQL) in another file - is that possible without running any DOS commands?

    Something like header.txt+myfile.xml???

    Thanks so much!

    -Parul

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by ParulV
    Hi folks!

    I have a question - do you know if there is a sql command to merge two files?
    I'm struggling to understand why this would be done inside SQL. A couple of thoughts come to mind:

    If you're using the FOR XML option to generate formatted XML, you simply need to add the <?xml version="1.0"?><root> and </root> tags to the beginning and end of the raw stream (because SQL doesn't do that for you). that can be done with a straightforward text concatenation (+) operator.

    If you are trying to "merge" two documents (something like a transform), then that is better handled using something other than T-SQL.

    Could you provide a bit more detail on what you are looking for?

    Regards,

    hmscott
    Have you hugged your backup today?

  3. #3
    Join Date
    Oct 2002
    Posts
    74
    Exactly, all I need to add is <?xml version="1.0"?> to the beginning of the XML file. I did not add it at the time I was writing my selects, because I figured I would need the closing tag. I hope that makes it better?!

    Thanks!

  4. #4
    Join Date
    Oct 2002
    Posts
    74
    Can you please explain your solution with an example?

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •