Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. File Creation or BCP utility

File Creation or BCP utility

Scheduled Pinned Locked Moved Database
toolshelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alwinSCH
    wrote on last edited by
    #1

    Helo, Can anybody help me! I have 3 tables first 1 have a header table with one row the second table are all the data records and the third is a trailer table! So now i want to create 1 file with all the fields of the header table separated through ; then new line, the data table with the fields separated through ; and finally the trailer table with fields separated through ; i think i can do this with Bcp utility or something like this, but i don't know how! Please help! Thank you

    W 1 Reply Last reply
    0
    • A alwinSCH

      Helo, Can anybody help me! I have 3 tables first 1 have a header table with one row the second table are all the data records and the third is a trailer table! So now i want to create 1 file with all the fields of the header table separated through ; then new line, the data table with the fields separated through ; and finally the trailer table with fields separated through ; i think i can do this with Bcp utility or something like this, but i don't know how! Please help! Thank you

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      You can create a SQL statement giving you correct result set and then save the result to a file. Use UNION and concatenate all fields from a table to a single field using desired separator Mika

      A 1 Reply Last reply
      0
      • W Wendelius

        You can create a SQL statement giving you correct result set and then save the result to a file. Use UNION and concatenate all fields from a table to a single field using desired separator Mika

        A Offline
        A Offline
        alwinSCH
        wrote on last edited by
        #3

        Ok, thank you but i want to put this in a stored Procedure... So i can call it from out of a program! A.

        A W 2 Replies Last reply
        0
        • A alwinSCH

          Ok, thank you but i want to put this in a stored Procedure... So i can call it from out of a program! A.

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          Well, you have several options You can use BCP (with a stored proc or a select) and a format file to create an output file, but this relies on ALL rows having the same number of fields You can use the idea of concatonating the fields together with your delimiter and use this query in your bcp with effectively a single field per rocord You can just read the data into your program and write the file yourself. Try Goggling for format files in bcp There are probably other ways too, but I can't be bothered to do your job any more...

          Bob Ashfield Consultants Ltd

          1 Reply Last reply
          0
          • A alwinSCH

            Ok, thank you but i want to put this in a stored Procedure... So i can call it from out of a program! A.

            W Offline
            W Offline
            Wendelius
            wrote on last edited by
            #5

            It doesn't matter. You can return the result set from procedure almost like you can return it from SELECT statement so wrapping the statement into procedure is ok.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups